[PATCH] Merge OR of ICMPs of single bit differences

Chandler Carruth chandlerc at google.com
Sat Apr 13 09:37:39 PDT 2013


Agreed. Especially about ensuring we canonicalize even user written
variations of the <u variant.
On Apr 13, 2013 9:19 AM, "Duncan Sands" <baldrick at free.fr> wrote:

> Hi David,
>
> On 13/04/13 00:31, David Majnemer wrote:
>
>> This patch reorders two transforms that collide with each other:
>>
>> One performs: (X == 13 | X == 14) -> X-13 <u 2
>> The other: (A == C1 || A == C2) -> (A & ~(C1 ^ C2)) == C1
>>
>> The problem is that there are certain values of C1 and C2 that trigger
>> both
>> transforms but the first one blocks out the second, this generates
>> suboptimal code.
>>
>> Reordering the transforms should be better in every case and allows us to
>> do
>> interesting stuff like turn:
>>    %shr = lshr i32 %X, 4
>>    %and = and i32 %shr, 15
>>    %add = add i32 %and, -14
>>    %tobool = icmp ne i32 %add, 0
>>
>> into:
>>    %and = and i32 %X, 240
>>    %tobool = icmp ne i32 %and, 224
>>
>
> this seems reasonable to me.  Another possibility is to recognize that some
> forms of "X-13 <u 2" can be turned into "(A & ~(C1 ^ C2)) == C1", which
> would
> catch hand-written cases of this coming straight from the original source
> code.
> Personally I think you should apply your patch and maybe consider the
> second
> possibility as an additional, future, optimization that could be
> implemented.
>
> Ciao, Duncan.
> ______________________________**_________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130413/2e58b9d4/attachment.html>


More information about the llvm-commits mailing list