[llvm] [BDCE] Handle multi-use `select` of `and`s on demanded bits (PR #79688)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 27 06:12:33 PST 2024


nikic wrote:

> Could you kindly provide an example showing how not restricting this to the `select` may be beneficial? We don't need to specialize it for the `select`, but restricting the input space looked reasonable to me.

You can replace the select with pretty much any instruction that transfers demanded bits, e.g. https://alive2.llvm.org/ce/z/om-5yP.

> 
> > You should only be looking at the demanded bits of the and.
> 
> You mean we should only be looking at the demanded bits of the instruction itself when the operand analyzed is the `and`? I don't see how the optimization can take place if the instruction examined is not the multi-use instruction.

I would expect you to query the demanded bits of the `and` instruction, similar to the code directly above that handles `sext`. Unless I'm missing something, that will cover the motivating pattern.

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


More information about the llvm-commits mailing list