Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Unified Diff: src/compiler/representation-change.cc

Issue 1908093002: [turbofan] Optimize tagged conversion based on type. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/representation-change.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/representation-change.cc
diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc
index 5744de1d54c0028785fb353eb0e2165d069c58ff..404eb1c16cb7c38ccec1e9f5cefea7d4b94ad01c 100644
--- a/src/compiler/representation-change.cc
+++ b/src/compiler/representation-change.cc
@@ -190,10 +190,12 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
if (output_rep == MachineRepresentation::kBit) {
op = simplified()->ChangeBitToBool();
} else if (IsWord(output_rep)) {
- if (output_type->Is(Type::Unsigned32())) {
- op = simplified()->ChangeUint32ToTagged();
+ if (output_type->Is(Type::Signed31())) {
+ op = simplified()->ChangeInt31ToTagged();
} else if (output_type->Is(Type::Signed32())) {
op = simplified()->ChangeInt32ToTagged();
+ } else if (output_type->Is(Type::Unsigned32())) {
+ op = simplified()->ChangeUint32ToTagged();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTagged);
@@ -201,9 +203,24 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
} else if (output_rep ==
MachineRepresentation::kFloat32) { // float32 -> float64 -> tagged
node = InsertChangeFloat32ToFloat64(node);
+ // TODO(bmeurer): Pass -0 hint to ChangeFloat64ToTagged.
op = simplified()->ChangeFloat64ToTagged();
} else if (output_rep == MachineRepresentation::kFloat64) {
- op = simplified()->ChangeFloat64ToTagged();
+ if (output_type->Is(Type::Signed31())) { // float64 -> int32 -> tagged
+ node = InsertChangeFloat64ToInt32(node);
+ op = simplified()->ChangeInt31ToTagged();
+ } else if (output_type->Is(
+ Type::Signed32())) { // float64 -> int32 -> tagged
+ node = InsertChangeFloat64ToInt32(node);
+ op = simplified()->ChangeInt32ToTagged();
+ } else if (output_type->Is(
+ Type::Unsigned32())) { // float64 -> uint32 -> tagged
+ node = InsertChangeFloat64ToUint32(node);
+ op = simplified()->ChangeUint32ToTagged();
+ } else {
+ // TODO(bmeurer): Pass -0 hint to ChangeFloat64ToTagged.
+ op = simplified()->ChangeFloat64ToTagged();
+ }
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTagged);
@@ -528,6 +545,13 @@ Node* RepresentationChanger::InsertChangeFloat32ToFloat64(Node* node) {
return jsgraph()->graph()->NewNode(machine()->ChangeFloat32ToFloat64(), node);
}
+Node* RepresentationChanger::InsertChangeFloat64ToUint32(Node* node) {
+ return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToUint32(), node);
+}
+
+Node* RepresentationChanger::InsertChangeFloat64ToInt32(Node* node) {
+ return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToInt32(), node);
+}
Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
« no previous file with comments | « src/compiler/representation-change.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698