This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by ab on Dec 5 2014, 3:15 PM.

Details

Summary

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

Diff Detail

Event Timeline

ab updated this revision to Diff 17003.Dec 5 2014, 3:15 PM
ab retitled this revision from to [X86] Teach FCOPYSIGN lowering to recognize constant magnitudes..
ab updated this object.
ab edited the test plan for this revision. (Show Details)
ab added a subscriber: Unknown Object (MLST).
ab updated this object.Dec 5 2014, 3:19 PM
ab updated this object.
ab updated this object.

Should this be target independent?

—Owen

ab added a comment.Jan 5 2015, 9:26 AM

Ping?

  • Ahmed
resistor accepted this revision.Jan 5 2015, 11:02 PM
resistor added a reviewer: resistor.

LGTM.

This revision is now accepted and ready to land.Jan 5 2015, 11:02 PM
This revision was automatically updated to reflect the committed changes.
test/CodeGen/X86/copysign-constant-magnitude.ll