[PATCH] D122152: [InstCombine] Fold two select patterns into and-or

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 28 12:46:05 PDT 2022


spatel added a comment.

In D122152#3411608 <https://reviews.llvm.org/D122152#3411608>, @bcl5980 wrote:

> In D122152#3411428 <https://reviews.llvm.org/D122152#3411428>, @spatel wrote:
>
>> LGTM.
>>
>> It's not clear how much of 'or' bitwise logic combining we want to replicate for select-of-bools, but this seems ok for now.
>>
>> Ie, if we are willing to freeze, then any select-of-bools can be converted to logic ops. If the condition is itself composed of bitwise logic with a repeated value, then there's probably some logic reduction that can happen. For example if we change the 'not' on one of the patterns here:
>> https://alive2.llvm.org/ce/z/BsyhPk
>
> Thanks for the finding.
> i1 logic space with add is an abel group(should be ring)
> and -> a * b
> xor  -> a + b
> or    -> a * b + a + b
> not  -> a + 1
> select -> c * a + (c + 1) * b

That's an interesting way to view it.

> I'm not sure we need to do this in code or not in the future.

I don't know either. If we have more motivating bugs with missed optimizations like this one, then we can try harder.

> @spatel Can you help me to check in the code ? 
> name: chenglin.bi
> email: chenglin.bi at cixcomputing.com

Yes - I'll commit after applying and rebuilding locally.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122152/new/

https://reviews.llvm.org/D122152



More information about the llvm-commits mailing list