[llvm] [DemandedBits] Add div/rem support (PR #148853)

Panagiotis K via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 05:53:51 PDT 2025


karouzakisp wrote:

> @karouzakisp Here are the proofs: https://alive2.llvm.org/ce/z/hYWDwZ
> 
> This shows that urem, udiv and srem handling is correct and sdiv handling is incorrect. Please try to provide this form of proof for all demanded bits transform.
> 
> Note that handling urem and udiv for power of two divisor is actually useless because these will be converted to and / lshr. Only handling srem and sdiv is useful.

@nikic
Thanks for the proofs. I will try to keep kind of the same format on the other PRs.

Regarding the udiv/urem being useless, I thought some transformations might happen. But, are we sure that the conversion will happen before any pass cares about DemandedBits at all?


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


More information about the llvm-commits mailing list