[llvm] [InstCombine] Add combines for unsigned comparison of absolute value to constant (PR #176148)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 10:20:53 PST 2026


================
@@ -4301,6 +4301,42 @@ Instruction *InstCombinerImpl::foldICmpIntrinsicWithConstant(ICmpInst &Cmp,
                             II->getArgOperand(1));
     }
     break;
+  case Intrinsic::abs: {
+    if (!Cmp.getOperand(0)->hasOneUse())
+      return nullptr;
+
+    Value *X = II->getArgOperand(0);
+    bool IntMinIsPoison =
+        dyn_cast<ConstantInt>(II->getArgOperand(1))->getValue().isOne();
----------------
dtcxzyw wrote:

```suggestion
        cast<ConstantInt>(II->getArgOperand(1))->getValue().isOne();
```

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


More information about the llvm-commits mailing list