[llvm] [InstSimplify] Simplify the select with integer comparison relationship (PR #66668)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 19:08:03 PST 2023


================
@@ -8294,6 +8294,17 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
   if (areMatchingOperands(L0, L1, R0, R1, AreSwappedOps))
     return isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps);
 
+  if (LPred == ICmpInst::ICMP_SGT) {
+    Value *X;
+    Value *Y;
+    const APInt *CI;
+    // x > y and C <= 0 ==> x -nsw y < C is false
+    if (match(R0, m_NSWSub(m_Value(X), m_Value(Y))) && match(R1, m_APInt(CI)) &&
+        areMatchingOperands(L0, L1, X, Y, AreSwappedOps) && CI->isNonPositive())
+      if (isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps) == false)
----------------
vfdff wrote:

the return value of `isImpliedCondMatchingOperands` may be **false**, **true** or **null**, so `!isImplied...` is not equal to `isImplied... == false`

https://github.com/llvm/llvm-project/pull/66668


More information about the llvm-commits mailing list