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

Unified Diff: src/compiler/common-operator-reducer.cc

Issue 2308303003: [turbofan] Fold "boolean not"-like Selects into branches. (Closed)
Patch Set: Created 4 years, 3 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/unittests/compiler/common-operator-reducer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/common-operator-reducer.cc
diff --git a/src/compiler/common-operator-reducer.cc b/src/compiler/common-operator-reducer.cc
index 9527c754e4ebdc4fd4400b97de82d997fbae0cc9..c5ced20373afe9574ec1c4f81136019d00eee651 100644
--- a/src/compiler/common-operator-reducer.cc
+++ b/src/compiler/common-operator-reducer.cc
@@ -77,8 +77,12 @@ Reduction CommonOperatorReducer::ReduceBranch(Node* node) {
// Swap IfTrue/IfFalse on {branch} if {cond} is a BooleanNot and use the input
// to BooleanNot as new condition for {branch}. Note we assume that {cond} was
// already properly optimized before we get here (as guaranteed by the graph
- // reduction logic).
- if (cond->opcode() == IrOpcode::kBooleanNot) {
+ // reduction logic). The same applies if {cond} is a Select acting as boolean
+ // not (i.e. true being returned in the false case and vice versa).
+ if (cond->opcode() == IrOpcode::kBooleanNot ||
+ (cond->opcode() == IrOpcode::kSelect &&
+ DecideCondition(cond->InputAt(1)) == Decision::kFalse &&
+ DecideCondition(cond->InputAt(2)) == Decision::kTrue)) {
for (Node* const use : node->uses()) {
switch (use->opcode()) {
case IrOpcode::kIfTrue:
« no previous file with comments | « no previous file | test/unittests/compiler/common-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698