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

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

Issue 1477803002: [turbofan] Generalize representation inference for NumberAdd. (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 | 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 4e2e8029700164de3c3f05a9e82dabce547813da..94d29cc54da0c730cd33595ca4f404408bfffc51 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -559,9 +559,17 @@ class RepresentationSelector {
NodeProperties::GetType(node)->Is(Type::Signed32()));
}
- bool CanLowerToWord32AdditiveBinop(Node* node, Truncation use) {
+ bool CanLowerToInt32AdditiveBinop(Node* node, Truncation use) {
+ // It is safe to lower to word32 operation if:
+ // - the inputs are safe integers (so the low bits are not discarded), and
+ // - the uses can only observe the lowest 32 bits or they can recover the
+ // the value from the type.
+ // TODO(jarin): we could support the uint32 case here, but that would
+ // require setting kTypeUint32 as the output type. Eventually, we will want
+ // to use only the big types, then this should work automatically.
return BothInputsAre(node, safe_int_additive_range_) &&
- use.TruncatesToWord32();
+ (use.TruncatesToWord32() ||
+ NodeProperties::GetType(node)->Is(Type::Signed32()));
}
// Dispatching routine for visiting the node {node} with the usage {use}.
@@ -689,7 +697,7 @@ class RepresentationSelector {
case IrOpcode::kNumberSubtract: {
// Add and subtract reduce to Int32Add/Sub if the inputs
// are already integers and all uses are truncating.
- if (CanLowerToWord32AdditiveBinop(node, truncation)) {
+ if (CanLowerToInt32AdditiveBinop(node, truncation)) {
// => signed Int32Add/Sub
VisitInt32Binop(node);
if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
« 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