[llvm] [InstCombine] Fold converted urem to 0 if there's no overlapping bits (PR #71528)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 07:39:58 PST 2023


https://github.com/dtcxzyw requested changes to this pull request.

Please add a test for `X` is a power of 2 or zero.
```
define i64 @test_pow2_or_zero(i64 %arg) {
  %neg = sub i64 0, %arg
  %x = and i64 %neg, %arg
  %shl1 = shl i64 %x, 4
  %shl2 = shl i64 %x, 3
  %mask = add i64 %shl2, -1
  %rem = and i64 %shl1, %mask
  ret i64 %rem
}
```
Wonder if we need some negative tests here.


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


More information about the llvm-commits mailing list