[llvm] [ConstraintElim] Tighten bounds using inequalities with constants. (PR #213049)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 09:57:39 PDT 2026


================
@@ -1781,6 +1786,47 @@ void ConstraintInfo::addFact(CmpInst::Predicate Pred, Value *A, Value *B,
   // If the Pred is eq/ne, also add the fact to signed system.
   if (CmpInst::isEquality(Pred))
     addFactImpl(Pred, A, B, NumIn, NumOut, DFSInStack, true);
+  if (Pred == CmpInst::ICMP_NE)
+    tightenBoundUsingNe(A, B, NumIn, NumOut, DFSInStack);
+}
+
+void ConstraintInfo::tightenBoundUsingNe(
+    Value *A, Value *B, unsigned NumIn, unsigned NumOut,
+    SmallVectorImpl<StackEntry> &DFSInStack) {
+  if (!isa<ConstantInt>(B) || !A->getType()->isIntegerTy())
----------------
antoniofrighetto wrote:

Isn't the second check unreachable?

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


More information about the llvm-commits mailing list