This is an archive of the discontinued LLVM Phabricator instance.

Lower FNEG ( FABS (x) ) -> FNABS (x) [X86 codegen] PR20578
ClosedPublic

Authored by spatel on Sep 4 2014, 7:25 PM.

Details

Summary

Negative FABS of either a scalar or vector should be handled the same way on x86 with SSE/AVX: a single OR instruction of the FP operand with a constant to light up the sign bit(s)

I don't know if I've chosen the best or even the right way to bail out of lowering a FABS if it has an FNEG user. I want to lower any potential FNABS cases before lowering the FABS into an AND. If the FABS gets lowered first, then it's much harder to detect an FNABS opportunity - we'd have to look through a potential cast, then a constant pool load, then check the constant(s)...messy.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 13295.Sep 4 2014, 7:25 PM
spatel retitled this revision from to Lower FNEG ( FABS (x) ) -> FNABS (x) [X86 codegen] PR20578.
spatel updated this object.
spatel edited the test plan for this revision. (Show Details)
spatel added reviewers: chandlerc, nadav, hfinkel, andreadb.
spatel added a subscriber: Unknown Object (MLST).
delena added inline comments.Sep 26 2014, 2:50 PM
lib/Target/X86/X86ISelLowering.cpp
12344 ↗(On Diff #13295)

I think this check is not necessary because the graph always comes from bottom.

spatel added inline comments.Sep 26 2014, 4:23 PM
lib/Target/X86/X86ISelLowering.cpp
12344 ↗(On Diff #13295)

Thanks for looking at this, Elena.

Without this check, all of the vector tests in the proposed test file fail because we process the FNEG first. I don't know why this is different between scalar and vector, but it is.

spatel added inline comments.Sep 26 2014, 4:25 PM
lib/Target/X86/X86ISelLowering.cpp
12344 ↗(On Diff #13295)

Sorry - that should have been process the *FABS* first.

delena edited edge metadata.Sep 28 2014, 5:24 AM

Ok. You are right. I have no more comments.

  • Elena

Does anyone else have any feedback? LGTM?

I checked this code and it looks good to me.

  • Elena
spatel closed this revision.Oct 1 2014, 2:30 PM
spatel updated this revision to Diff 14295.

Closed by commit rL218822 (authored by @spatel).