[llvm] [InstCombine] Fold `ceil(X / (2 ^ C)) == 0` -> `X == 0` (PR #143683)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 13 03:26:08 PDT 2025


================
@@ -1298,6 +1299,23 @@ Instruction *InstCombinerImpl::foldICmpWithZero(ICmpInst &Cmp) {
     // eq/ne (mul X, Y)) with (icmp eq/ne X/Y) and if X/Y is known non-zero that
     // will fold to a constant elsewhere.
   }
+
+  // (X >> C) + ((X & ((1 << C) - 1)) != 0) == 0 -> X == 0
+  if (Pred == ICmpInst::ICMP_EQ) {
----------------
dtcxzyw wrote:

```suggestion
  if (ICmpInst::isEquality(Pred)) {
```

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


More information about the llvm-commits mailing list