[llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B))

Török Edwin edwintorok at gmail.com
Wed Jun 17 13:50:19 PDT 2009


On 2009-06-17 23:25, Dan Gohman wrote:
> On Jun 17, 2009, at 11:35 AM, Török Edwin wrote:
>
>   
>> Hi,
>>
>> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't  
>> folded,
>> the attached patch folds this into:
>> umax (zext t1 %X to %t0, zext t1 %Y to %t0).
>>
>> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) ->  sext t1
>> (umax (%X, %Y)) to %t0.
>>
>> zext is very often encountered in SCEV expressions on x86-64, since
>> pointer indexes for GEP are i64.
>>
>> Thoughts?
>>     
>
> Another question to ask is whether this kind of thing belongs in
> ScalarEvolution, or if it would be more appropriate for
> instcombine. Instcombine looks at all instructions in a program,
> while ScalarEvolution typically only looks at those related to
> loop iteration. Also, instcombine could more easily handle more
> generalized cases of this optimization, for example with umin.
>   

Yes, instcombine appears to do this transform already.

Best regards,
--Edwin



More information about the llvm-commits mailing list