// 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);
// 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);
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()));
}
}