[InstSimplify] fold exact divide to poison if it is known to not divide evenly
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: https://github.com/llvm/llvm-project/blob/82be8a1d2b00f6e89096b86f670a8be894c7b9e6/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L799 Also, see tests added with 7f0c1150. 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
Loading
Please sign in to comment