[llvm] [InstCombine] Added optimisation for trunc (Negated Pow2 >> x) to i1 (PR #157998)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 00:12:28 PDT 2025


nikic wrote:

> General proof lshr: https://alive2.llvm.org/ce/z/F5C4Lj
> ashr: https://alive2.llvm.org/ce/z/E2bLN7

These proofs aren't correct: They check for a power of two which is a negative number, which is not the same as a negated power of two.

Correct ones should be:

https://alive2.llvm.org/ce/z/vVfaJc
https://alive2.llvm.org/ce/z/8aAcgD

Note that these use `uge` without the -1, otherwise the transform is incorrect for the case where the negative power of two is -1.

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


More information about the llvm-commits mailing list