[PATCH] D122726: [x86] try to replace 0.0 in fcmp with negated operand

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 05:24:06 PDT 2022


spatel created this revision.
spatel added reviewers: pengfei, craig.topper, RKSimon.
Herald added subscribers: StephenFan, hiraditya, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This inverts a fold recently added to IR with:
3491f2f4b033 <https://reviews.llvm.org/rG3491f2f4b0336cdb788fed3ff03a4b31c58db14e>

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.


https://reviews.llvm.org/D122726

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/fp-stack-compare.ll
  llvm/test/CodeGen/X86/setcc-combine.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122726.419111.patch
Type: text/x-patch
Size: 7797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220330/883e1a52/attachment.bin>


More information about the llvm-commits mailing list