[llvm] [InstCombine] Fold `(icmp eq/ne (add nuw x, y), 0)` -> `(icmp eq/ne (or x, y), 0)` (PR #88088)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 23:54:16 PDT 2024


dtcxzyw wrote:

Missing fold: https://alive2.llvm.org/ce/z/DShc49
```
define i1 @src(i1 %x, i32 %z) {
  %22 = select i1 %x, i32 0, i32 255
  %23 = or i32 %z, %22
  %eq = icmp eq i32 %23, 0
  ret i1 %eq
}

define i1 @tgt(i1 %x, i32 %z) {
  %eq = icmp eq i32 %z, 0
  %and = and i1 %x, %eq
  ret i1 %and
}
```

See also https://github.com/dtcxzyw/llvm-opt-benchmark/pull/485/files#r1557018422


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


More information about the llvm-commits mailing list