[turbofan] Also update the BranchHint when merging a BooleanNot.
authorbmeurer <bmeurer@chromium.org>
Fri, 26 Jun 2015 12:08:11 +0000 (05:08 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 26 Jun 2015 12:08:26 +0000 (12:08 +0000)
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/1218443002

Cr-Commit-Position: refs/heads/master@{#29324}

src/compiler/common-operator-reducer.cc
src/compiler/common-operator.h
test/unittests/compiler/common-operator-reducer-unittest.cc

index 1ed05f1..c1cd75e 100644 (file)
@@ -99,6 +99,8 @@ Reduction CommonOperatorReducer::ReduceBranch(Node* node) {
     // since we tell the graph reducer that the {branch} was changed and the
     // graph reduction logic will ensure that the uses are revisited properly.
     node->ReplaceInput(0, cond->InputAt(0));
+    // Negate the hint for {branch}.
+    node->set_op(common()->Branch(NegateBranchHint(BranchHintOf(node->op()))));
     return Changed(node);
   }
   Decision const decision = DecideCondition(cond);
index 4d8b169..3b89b2c 100644 (file)
@@ -27,6 +27,19 @@ class Operator;
 // Prediction hint for branches.
 enum class BranchHint : uint8_t { kNone, kTrue, kFalse };
 
+inline BranchHint NegateBranchHint(BranchHint hint) {
+  switch (hint) {
+    case BranchHint::kNone:
+      return hint;
+    case BranchHint::kTrue:
+      return BranchHint::kFalse;
+    case BranchHint::kFalse:
+      return BranchHint::kTrue;
+  }
+  UNREACHABLE();
+  return hint;
+}
+
 inline size_t hash_value(BranchHint hint) { return static_cast<size_t>(hint); }
 
 std::ostream& operator<<(std::ostream&, BranchHint);
index c33d107..13d2d67 100644 (file)
@@ -187,6 +187,7 @@ TEST_F(CommonOperatorReducerTest, BranchWithBooleanNot) {
     EXPECT_THAT(branch, IsBranch(value, control));
     EXPECT_THAT(if_false, IsIfTrue(branch));
     EXPECT_THAT(if_true, IsIfFalse(branch));
+    EXPECT_EQ(NegateBranchHint(hint), BranchHintOf(branch->op()));
   }
 }