[PATCH] InstCombine: Optimize (1 << X) UPred CstP2 to X UPred Log2(CstP2)

David Majnemer david.majnemer at gmail.com
Mon Jun 24 10:44:51 PDT 2013


Ping x2.

On Monday, June 17, 2013, David Majnemer wrote:

> Ping.
>
>
> On Sun, Jun 9, 2013 at 8:15 PM, David Majnemer <david.majnemer at gmail.com<javascript:_e({}, 'cvml', 'david.majnemer at gmail.com');>
> > wrote:
>
>> On Sun, Jun 9, 2013 at 1:27 PM, David Majnemer <david.majnemer at gmail.com<javascript:_e({}, 'cvml', 'david.majnemer at gmail.com');>
>> > wrote:
>>
>>> On Sun, Jun 9, 2013 at 10:37 AM, Duncan Sands <duncan.sands at gmail.com<javascript:_e({}, 'cvml', 'duncan.sands at gmail.com');>
>>> > wrote:
>>>
>>>> Hi David,
>>>>
>>>>
>>>> On 09/06/13 14:10, David Majnemer wrote:
>>>>
>>>>> We may, after other optimizations, find ourselves with IR that looks
>>>>> like:
>>>>>
>>>>>    %shl = shl i32 1, %y
>>>>>    %cmp = icmp ult i32 %shl, 32
>>>>>
>>>>> However, we should transform it to:
>>>>>
>>>>>    %cmp = icmp ult i32 %y, 5
>>>>>
>>>>> The attached patch teaches visitICmpInstWithInstAndIntCst how to
>>>>> perform this
>>>>> transform.
>>>>>
>>>>
>>>> while the patch looks OK, I think it could be more general.  In your
>>>> example,
>>>> if the icmp ult was with, say, 30 then you still could have transformed
>>>> it.
>>>> In the case of an icmp eq comparison, if the RHS is not a power of two
>>>> then
>>>> it cannot be equal to the left hand side, so you could fold the
>>>> comparison to
>>>> false.
>>>>
>>>
>>> Thanks! I've attached an updated patch that implements additional
>>> transforms.
>>>
>>
>> And yet more transforms, it turns out we turn some unsigned comparisons
>> into signed comparisons. Optimize these too.
>>
>>
>>>
>>>
>>>>
>>>> Ciao, Duncan.
>>>> ______________________________**_________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu <javascript:_e({}, 'cvml',
>>>> '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/20130624/a780d5ba/attachment.html>


More information about the llvm-commits mailing list