[llvm] [ValueTracking] Handle non-canonical operand order in `isImpliedCondICmps` (PR #85575)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 17 13:51:36 PDT 2024
================
@@ -8532,6 +8532,15 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
CmpInst::Predicate LPred =
LHSIsTrue ? LHS->getPredicate() : LHS->getInversePredicate();
+ // We can have non-canonical operands here so canonicalize constant to L1/R1.
+ if (match(L0, m_ImmConstant())) {
+ std::swap(L0, L1);
+ LPred = ICmpInst::getSwappedPredicate(LPred);
+ }
+ if (match(R0, m_ImmConstant())) {
+ std::swap(R0, R1);
+ RPred = ICmpInst::getSwappedPredicate(RPred);
+ }
----------------
nikic wrote:
Can we drop the swapping code below now?
https://github.com/llvm/llvm-project/pull/85575
More information about the llvm-commits
mailing list