From: bmeurer Date: Fri, 26 Jun 2015 12:08:11 +0000 (-0700) Subject: [turbofan] Also update the BranchHint when merging a BooleanNot. X-Git-Tag: upstream/4.7.83~1716 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce0431d665bdb079b16c3daa1c27cf00967f4aa9;p=platform%2Fupstream%2Fv8.git [turbofan] Also update the BranchHint when merging a BooleanNot. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/1218443002 Cr-Commit-Position: refs/heads/master@{#29324} --- diff --git a/src/compiler/common-operator-reducer.cc b/src/compiler/common-operator-reducer.cc index 1ed05f1..c1cd75e 100644 --- a/src/compiler/common-operator-reducer.cc +++ b/src/compiler/common-operator-reducer.cc @@ -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); diff --git a/src/compiler/common-operator.h b/src/compiler/common-operator.h index 4d8b169..3b89b2c 100644 --- a/src/compiler/common-operator.h +++ b/src/compiler/common-operator.h @@ -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(hint); } std::ostream& operator<<(std::ostream&, BranchHint); diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc index c33d107..13d2d67 100644 --- a/test/unittests/compiler/common-operator-reducer-unittest.cc +++ b/test/unittests/compiler/common-operator-reducer-unittest.cc @@ -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())); } }