Commit ce0431d6 authored by bmeurer's avatar bmeurer Committed by Commit bot

[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}
parent 78794746
......@@ -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);
......
......@@ -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);
......
......@@ -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()));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment