[PATCH] [X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.

Ahmed Bougacha ahmed.bougacha at gmail.com
Mon Jan 5 09:25:47 PST 2015


Ping?
- Ahmed


On Fri, Dec 5, 2014 at 5:58 PM, Ahmed Bougacha <ahmed.bougacha at gmail.com> wrote:
> On Fri, Dec 5, 2014 at 5:48 PM, Owen Anderson <resistor at mac.com> wrote:
>> Should this be target independent?
>
> I don't think so, it's only after the copysign was expanded to bitwise
> ops that the constant folding is exposed.
> If the expansion happened earlier, other generic combines will do the
> optimization.
>
> - Ahmed
>
>> —Owen
>>
>>> On Dec 5, 2014, at 3:15 PM, Ahmed Bougacha <ahmed.bougacha at gmail.com> wrote:
>>>
>>> For code like:
>>>        float foo(float x) { return copysign(1.0, x); }
>>>
>>> We used to generate:
>>>       andps   <-0.000000e+00,0,0,0>, %xmm0
>>>       movss   <1.000000e+00>, %xmm1
>>>       andps   <nan>, %xmm1
>>>       orps            %xmm0, %xmm1
>>>
>>> Basically doing an abs(1.0f) in the two middle instructions.
>>>
>>> We now generate:
>>>        andps   <-0.000000e+00,0,0,0>, %xmm0
>>>        orps    <1.000000e+00,0,0,0>, %xmm0
>>>
>>> http://reviews.llvm.org/D6555
>>>
>>> Files:
>>>  lib/Target/X86/X86ISelLowering.cpp
>>>  test/CodeGen/X86/copysign-constant-magnitude.ll
>>>  test/CodeGen/X86/copysign-zero.ll
>>> <D6555.17003.patch>_______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>




More information about the llvm-commits mailing list