[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 7 Jan 2015 17:33:03 +0000 (17:33 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 7 Jan 2015 17:33:03 +0000 (17:33 +0000)
commitd412c608fcaee75a08160bcf4646257af9f82466
tree357e7670b736c8f1fecd2a96ce4f794ad221bb5d
parent1763c0ad7f5cfb773213c39261f5664683219c3e
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.

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

Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225357 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/copysign-constant-magnitude.ll [new file with mode: 0644]
test/CodeGen/X86/copysign-zero.ll [deleted file]