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

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

Issue 1455103002: [turbofan] Only infer signedness for Float64->Word32 representation change from the input type. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | test/cctest/compiler/test-representation-change.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/representation-change.h
diff --git a/src/compiler/representation-change.h b/src/compiler/representation-change.h
index 98de04d3a5fe916fedfe2e736046d38828633aa9..9ad253d481cf4c6a364840b3c8aa51dcc8973b11 100644
--- a/src/compiler/representation-change.h
+++ b/src/compiler/representation-change.h
@@ -58,8 +58,7 @@ class RepresentationChanger {
} else if (use_type & kRepBit) {
return GetBitRepresentationFor(node, output_type);
} else if (IsWord(use_type)) {
- return GetWord32RepresentationFor(node, output_type,
- use_type & kTypeUint32);
+ return GetWord32RepresentationFor(node, output_type);
} else if (use_type & kRepWord64) {
return GetWord64RepresentationFor(node, output_type);
} else {
@@ -245,8 +244,7 @@ class RepresentationChanger {
return jsgraph()->graph()->NewNode(op, node);
}
- Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type,
- bool use_unsigned) {
+ Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type) {
// Eagerly fold representation changes for constants.
switch (node->opcode()) {
case IrOpcode::kInt32Constant:
@@ -261,26 +259,34 @@ class RepresentationChanger {
}
// Select the correct X -> Word32 operator.
const Operator* op;
+ Type* type = NodeProperties::GetType(node);
if (output_type & kRepBit) {
return node; // Sloppy comparison -> word32
} else if (output_type & kRepFloat64) {
- if (output_type & kTypeUint32 || use_unsigned) {
+ if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) {
op = machine()->ChangeFloat64ToUint32();
- } else {
+ } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) {
op = machine()->ChangeFloat64ToInt32();
+ } else {
+ op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
}
} else if (output_type & kRepFloat32) {
node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32
- if (output_type & kTypeUint32 || use_unsigned) {
+ if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) {
op = machine()->ChangeFloat64ToUint32();
- } else {
+ } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) {
op = machine()->ChangeFloat64ToInt32();
+ } else {
+ op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
}
} else if (output_type & kRepTagged) {
- if (output_type & kTypeUint32 || use_unsigned) {
+ if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) {
op = simplified()->ChangeTaggedToUint32();
- } else {
+ } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) {
op = simplified()->ChangeTaggedToInt32();
+ } else {
+ node = InsertChangeTaggedToFloat64(node);
+ op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
}
} else {
return TypeError(node, output_type, kRepWord32);
« no previous file with comments | « no previous file | test/cctest/compiler/test-representation-change.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698