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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 638533002: Fix bugs in lowering NumberToInt32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « no previous file | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index c64c00979d6a1fd524146fd127ef63d75b1dfc43..74463a96c8787ab0532fdd5b4eb36200a6222b1e 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -502,44 +502,38 @@ class RepresentationSelector {
}
case IrOpcode::kNumberToInt32: {
MachineTypeUnion use_rep = use & kRepMask;
- if (lower()) {
- MachineTypeUnion in = GetInfo(node->InputAt(0))->output;
- if ((in & kTypeMask) == kTypeInt32 || (in & kRepMask) == kRepWord32) {
- // If the input has type int32, or is already a word32, just change
- // representation if necessary.
- VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep);
- DeferReplacement(node, node->InputAt(0));
- } else {
- // Require the input in float64 format and perform truncation.
- // TODO(turbofan): avoid a truncation with a smi check.
- VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32);
- node->set_op(lowering->machine()->TruncateFloat64ToInt32());
- }
+ Node* input = node->InputAt(0);
+ MachineTypeUnion in = GetInfo(input)->output;
+ if (NodeProperties::GetBounds(input).upper->Is(Type::Signed32()) ||
+ (in & kTypeMask) == kTypeInt32 || (in & kRepMask) == kRepWord32) {
+ // If the input has type int32, or is already a word32, just change
+ // representation if necessary.
+ VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
} else {
- // Propagate a type to the input, but pass through representation.
- VisitUnop(node, kTypeInt32, kTypeInt32 | use_rep);
+ // Require the input in float64 format and perform truncation.
+ // TODO(turbofan): avoid a truncation with a smi check.
+ VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32);
+ if (lower())
+ node->set_op(lowering->machine()->TruncateFloat64ToInt32());
}
break;
}
case IrOpcode::kNumberToUint32: {
MachineTypeUnion use_rep = use & kRepMask;
- if (lower()) {
- MachineTypeUnion in = GetInfo(node->InputAt(0))->output;
- if ((in & kTypeMask) == kTypeUint32 ||
- (in & kRepMask) == kRepWord32) {
- // The input has type int32, just change representation.
- VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep);
- DeferReplacement(node, node->InputAt(0));
- } else {
- // Require the input in float64 format to perform truncation.
- // TODO(turbofan): avoid the truncation with a smi check.
- VisitUnop(node, kTypeUint32 | kRepFloat64,
- kTypeUint32 | kRepWord32);
- node->set_op(lowering->machine()->TruncateFloat64ToInt32());
- }
+ Node* input = node->InputAt(0);
+ MachineTypeUnion in = GetInfo(input)->output;
+ if (NodeProperties::GetBounds(input).upper->Is(Type::Unsigned32()) ||
+ (in & kTypeMask) == kTypeUint32) {
+ // If the input has type uint32, just change representation.
+ VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
} else {
- // Propagate a type to the input, but pass through representation.
- VisitUnop(node, kTypeUint32, kTypeUint32 | use_rep);
+ // Require the input in float64 format and perform truncation.
+ // TODO(turbofan): avoid a truncation with a smi check.
+ VisitUnop(node, kTypeUint32 | kRepFloat64, kTypeUint32 | kRepWord32);
+ if (lower())
+ node->set_op(lowering->machine()->TruncateFloat64ToInt32());
}
break;
}
« no previous file with comments | « no previous file | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698