Linear blend -> select InstCombine

Jean-Luc Duprat jduprat at apple.com
Fri May 3 18:43:47 PDT 2013


And now the patch really is attached…

JL
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mix.patch
Type: application/octet-stream
Size: 4566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130503/40a7651e/attachment.obj>
-------------- next part --------------






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



More information about the llvm-commits mailing list