This is related to the discussion in D140665. I was looking over the demanded bits implementation in IR and noticed that we just bail out of a potential fold if a udiv is exact:82be8a1d2b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (L799)Also, see tests added with7f0c11509e. Then, I saw that we could lose a fold to poison if we zap the exact with that transform, so this patch tries to catch that as a preliminary step. Alive2 proofs: https://alive2.llvm.org/ce/z/zCjKM7 https://alive2.llvm.org/ce/z/-tz_RK (trailing zeros must be "less-than") https://alive2.llvm.org/ce/z/c9CMsJ (general proof and specific example) Differential Revision: https://reviews.llvm.org/D140733
70 KiB
70 KiB