This is an archive of the discontinued LLVM Phabricator instance.

[x86] try to replace 0.0 in fcmp with negated operand
ClosedPublic

Authored by spatel on Mar 30 2022, 5:24 AM.

Details

Summary

This inverts a fold recently added to IR with:
3491f2f4b033

We can put -bidirectional on the Alive2 examples to show that the reverse transforms work:
https://alive2.llvm.org/ce/z/8iVQwB

The motivation for the IR change was to improve matching to 'fabs' in IR (see https://github.com/llvm/llvm-project/issues/38828 ), but it regressed x86 codegen for 'not-quite-fabs' patterns like (X > -X) ? X : -X.
Ie, when there is no fast-math (nsz), the cmp+select is not a proper fabs operation, but it does map nicely to the unusual NAN semantics of MINSS/MAXSS.

I drafted this as a target-independent fold, but it doesn't appear to help any other targets and seems to cause regressions for SystemZ at least.

Diff Detail

Event Timeline

spatel created this revision.Mar 30 2022, 5:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2022, 5:24 AM
spatel requested review of this revision.Mar 30 2022, 5:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2022, 5:24 AM
pengfei accepted this revision.Mar 30 2022, 5:55 AM

LGTM, thanks!

This revision is now accepted and ready to land.Mar 30 2022, 5:55 AM
This revision was landed with ongoing or failed builds.Mar 31 2022, 6:18 AM
This revision was automatically updated to reflect the committed changes.