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

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

Issue 683873002: [turbofan] Avoid unnecessary (u)int32<->float64 changes in simplified lowering. (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 | no next file » | 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 1a4ca96b072f6a1881ed2ba458fbe847ee19f1e6..f2e679abd77a7815d5b38680459a596a072d9b9e 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -308,43 +308,38 @@ class RepresentationSelector {
MachineType output = kMachNone;
MachineType propagate = kMachNone;
- if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) {
- // legal = kRepTagged | kRepFloat64 | kRepWord32;
- if ((use & kRepMask) == kRepTagged) {
- // only tagged uses.
- output = kRepTagged;
- propagate = kRepTagged;
- } else if ((use & kRepMask) == kRepFloat64) {
+ if ((use & kRepMask) == kRepTagged) {
+ // only tagged uses.
+ output = kRepTagged;
+ propagate = kRepTagged;
+ } else if (IsSafeIntAdditiveOperand(node)) {
+ // Integer within [-2^52, 2^52] range.
+ if ((use & kRepMask) == kRepFloat64) {
// only float64 uses.
output = kRepFloat64;
propagate = kRepFloat64;
- } else {
- // multiple uses.
+ } else if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) {
+ // multiple uses, but we are within 32 bits range => pick kRepWord32.
+ output = kRepWord32;
+ propagate = kRepWord32;
+ } else if ((use & kRepMask) == kRepWord32 ||
+ (use & kTypeMask) == kTypeInt32 ||
+ (use & kTypeMask) == kTypeUint32) {
+ // The type is a safe integer, but we only use 32 bits.
output = kRepWord32;
propagate = kRepWord32;
- }
- } else if (upper->Is(Type::Boolean())) {
- // legal = kRepTagged | kRepBit;
- if ((use & kRepMask) == kRepTagged) {
- // only tagged uses.
- output = kRepTagged;
- propagate = kRepTagged;
- } else {
- // multiple uses.
- output = kRepBit;
- propagate = kRepBit;
- }
- } else if (upper->Is(Type::Number())) {
- // legal = kRepTagged | kRepFloat64;
- if ((use & kRepMask) == kRepTagged) {
- // only tagged uses.
- output = kRepTagged;
- propagate = kRepTagged;
} else {
- // multiple uses.
output = kRepFloat64;
propagate = kRepFloat64;
}
+ } else if (upper->Is(Type::Boolean())) {
+ // multiple uses => pick kRepBit.
+ output = kRepBit;
+ propagate = kRepBit;
+ } else if (upper->Is(Type::Number())) {
+ // multiple uses => pick kRepFloat64.
+ output = kRepFloat64;
+ propagate = kRepFloat64;
} else {
// legal = kRepTagged;
output = kRepTagged;
@@ -648,13 +643,15 @@ class RepresentationSelector {
case IrOpcode::kNumberToInt32: {
MachineTypeUnion use_rep = use & kRepMask;
Node* input = node->InputAt(0);
+ Type* in_upper = NodeProperties::GetBounds(input).upper;
MachineTypeUnion in = GetInfo(input)->output;
- if (NodeProperties::GetBounds(input).upper->Is(Type::Signed32())) {
+ if (in_upper->Is(Type::Signed32())) {
// If the input has type int32, pass through representation.
VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep);
if (lower()) DeferReplacement(node, node->InputAt(0));
} else if ((in & kTypeMask) == kTypeUint32 ||
(in & kTypeMask) == kTypeInt32 ||
+ in_upper->Is(Type::Unsigned32()) ||
titzer 2014/10/28 15:10:42 Something feels a little fishy here. What about ma
(in & kRepMask) == kRepWord32) {
// Just change representation if necessary.
VisitUnop(node, kTypeInt32 | kRepWord32, kTypeInt32 | kRepWord32);
@@ -671,13 +668,15 @@ class RepresentationSelector {
case IrOpcode::kNumberToUint32: {
MachineTypeUnion use_rep = use & kRepMask;
Node* input = node->InputAt(0);
+ Type* in_upper = NodeProperties::GetBounds(input).upper;
MachineTypeUnion in = GetInfo(input)->output;
- if (NodeProperties::GetBounds(input).upper->Is(Type::Unsigned32())) {
+ if (in_upper->Is(Type::Unsigned32())) {
// If the input has type uint32, pass through representation.
VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep);
if (lower()) DeferReplacement(node, node->InputAt(0));
} else if ((in & kTypeMask) == kTypeUint32 ||
(in & kTypeMask) == kTypeInt32 ||
+ in_upper->Is(Type::Signed32()) ||
(in & kRepMask) == kRepWord32) {
// Just change representation if necessary.
VisitUnop(node, kTypeUint32 | kRepWord32, kTypeUint32 | kRepWord32);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698