Linear blend -> select InstCombine

Nadav Rotem nrotem at apple.com
Fri May 3 21:04:26 PDT 2013


Hi Jean-Luc, 

LGTM.  I remember that ISPC was generating code like this (for vectors). One nit picking, there is an extra pair of braces around the second swap statement.  

Thanks,
Nadav

On May 3, 2013, at 6:43 PM, Jean-Luc Duprat <jduprat at apple.com> wrote:

> And now the patch really is attached…
> 
> JL
> <mix.patch>
> 
> 
> 
> 
> 
> On May 3, 2013, at 18:35 , Jean-Luc Duprat <jduprat at apple.com> wrote:
> 
>> The attached patch provides instcombines for the following 3 cases:
>> 
>> A * (1 - (uitofp i1 C)) -> select C, 0, A
>> B * (uitofp i1 C) -> select C, B, 0
>> select C, 0, A + select C, B, 0 -> select C, B, A
>> 
>> These come up in code that has been hand-optimized from a select to a linear blend, on platforms where that may have mattered; that is we want to do the following transform:
>> A*(1 - uitofp i1 C) + B*(uitofp i1 C) -> select C, A, B
>> 
>> Test cases included in the patch, here are the 3 combine optimizations at work together:
>> 
>> $ cat foo.ll
>> define float @test3(float %A, float %B, i1 %C) {
>> EntryBlock:
>> %cf = uitofp i1 %C to float
>> %mc = fsub float 1.000000e+00, %cf
>> %p1 = fmul fast float %A, %mc
>> %p2 = fmul fast float %B, %cf
>> %s1 = fadd fast float %p1, %p2
>> ret float %s1
>> }
>> 
>> $ opt -instcombine -S fool.ll
>> define float @test3(float %A, float %B, i1 %C) {
>> EntryBlock:
>> %s1 = select i1 %C, float %B, float %A
>> ret float %s1
>> }
>> 
>> 
>> JL
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> 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/20130503/22eff03e/attachment.html>


More information about the llvm-commits mailing list