[llvm] [ValueTracking] Handle non-canonical operand order in `isImpliedCondICmps` (PR #85575)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sun Mar 17 12:57:38 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);
+  }
----------------
goldsteinn wrote:
Checking matching does work (didn't see any difference between the two). Ill update.
https://github.com/llvm/llvm-project/pull/85575
    
    
More information about the llvm-commits
mailing list