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

Unified Diff: src/compiler/control-reducer.cc

Issue 691513002: [turbofan] Introduce new Select operator to improve bounds checking. (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 | « src/compiler/common-operator.cc ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc
index 533fb23997614e8c2503a2f1959c77d4424257a5..b06076457e5e5ae723655486a1fde289dc0e3147 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -322,6 +322,8 @@ class ControlReducerImpl {
case IrOpcode::kLoop:
case IrOpcode::kMerge:
return ReduceMerge(node);
+ case IrOpcode::kSelect:
+ return ReduceSelect(node);
case IrOpcode::kPhi:
case IrOpcode::kEffectPhi:
return ReducePhi(node);
@@ -330,6 +332,32 @@ class ControlReducerImpl {
}
}
+ // Reduce redundant selects.
+ Node* ReduceSelect(Node* const node) {
+ Node* const cond = node->InputAt(0);
+ Node* const tvalue = node->InputAt(1);
+ Node* const fvalue = node->InputAt(2);
+ if (tvalue == fvalue) return tvalue;
+ switch (cond->opcode()) {
+ case IrOpcode::kInt32Constant:
+ return Int32Matcher(cond).Is(0) ? fvalue : tvalue;
+ case IrOpcode::kInt64Constant:
+ return Int64Matcher(cond).Is(0) ? fvalue : tvalue;
+ case IrOpcode::kNumberConstant:
+ return NumberMatcher(cond).Is(0) ? fvalue : tvalue;
+ case IrOpcode::kHeapConstant: {
+ Handle<Object> object =
+ HeapObjectMatcher<Object>(cond).Value().handle();
+ if (object->IsTrue()) return tvalue;
+ if (object->IsFalse()) return fvalue;
+ break;
+ }
+ default:
+ break;
+ }
+ return node;
+ }
+
// Reduce redundant phis.
Node* ReducePhi(Node* node) {
int n = node->InputCount();
@@ -406,6 +434,9 @@ class ControlReducerImpl {
case IrOpcode::kInt32Constant:
is_true = !Int32Matcher(cond).Is(0);
break;
+ case IrOpcode::kInt64Constant:
+ is_true = !Int64Matcher(cond).Is(0);
+ break;
case IrOpcode::kNumberConstant:
is_true = !NumberMatcher(cond).Is(0);
break;
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698