[PATCH] Teach Instcombine to use the nsw attribute for signed comparisons to 0 of (shl %v, Cst) or (mul %v, Cst)

Arnaud A. de Grandmaison arnaud.adegm at gmail.com
Mon Mar 18 03:56:25 PDT 2013


On 03/18/2013 11:40 AM, Duncan Sands wrote:
> Hi Arnaud,
>
> On 17/03/13 18:11, Arnaud de Grandmaison wrote:
>> The attached patch teaches InstCombine/visitICmpInstWithInstAndIntCst to
>> optimize 'icmp pred (mul %v, Cst), 0' when the mul has the nsw
>> attribute set.
>>   The comparison can the be performed on the mul RHS.
>>
>> The patch also handles the case of the mul in strength reduced form :
>> shl
>
> it looks like this will transform
>
>   %mul = mul nsw i32 %x, 0
>   %cmp = icmp sgt i32 %mul, 0
>
> into
>
>   icmp sgt i32 %x, 0
>
> which is wrong.
>

Good catch ! The patch is being updated (after Nicks' comments) to
handle this case.

Thanks Duncan.

Cheers,
--
Arnaud

> Ciao, Duncan.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


-- 
Arnaud A. de Grandmaison




More information about the llvm-commits mailing list