[clang] [llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 23 13:45:08 PST 2024
veera-sivarajan wrote:
> The more idiomatic way to handle this is to have something like if (match(FalseVal, m_Constant())) { std::swap(TrueVal, FalseVal); Pred = ICmpInst::getInversePredicate(Pred); } and then you no longer have to deal with which operand the constant is in.
Thank you for the detailed feedback.
This simplifies the pattern match but I still have to conditionally assign `NewTrue` and `NewFalse` because `matchDecomposedSelectPattern()` takes an `ICmpInst` and not a `ICmpInst:Predicate`.
https://github.com/llvm/llvm-project/pull/116888
More information about the cfe-commits
mailing list