[llvm] [ConstraintElim] Add facts for llvm.abs >= 0 (PR #79070)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 13:17:44 PST 2024


================
@@ -1730,7 +1730,10 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
     if (!CB.isConditionFact()) {
       Value *X;
       if (match(CB.Inst, m_Intrinsic<Intrinsic::abs>(m_Value(X)))) {
-        // TODO: Add CB.Inst >= 0 fact.
+        // If is_int_min_poison is true then we may assume llvm.abs >= 0.
+        if (!cast<ConstantInt>(CB.Inst->getOperand(1))->isZero())
----------------
nikic wrote:

```suggestion
        if (cast<ConstantInt>(CB.Inst->getOperand(1))->isOne())
```

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


More information about the llvm-commits mailing list