[PATCH] D47389: guard fneg with fmf sub flags
Michael Berg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 5 11:54:01 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334037: guard fneg with fmf sub flags (authored by mcberg2017, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D47389?vs=150016&id=150019#toc
Repository:
rL LLVM
https://reviews.llvm.org/D47389
Files:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll
Index: llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll
===================================================================
--- llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll
+++ llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll
@@ -460,28 +460,25 @@
; -(X - Y) --> (Y - X)
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
-; FMFDEBUG: fsub {{t[0-9]+}}, {{t[0-9]+}}
+; FMFDEBUG: fsub nsz {{t[0-9]+}}, {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
-; GLOBALDEBUG: fsub {{t[0-9]+}}, {{t[0-9]+}}
+; GLOBALDEBUG: fsub nsz {{t[0-9]+}}, {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
define float @fneg_fsub_nozeros_1(float %x, float %y, float %z) {
; FMF-LABEL: fneg_fsub_nozeros_1:
; FMF: # %bb.0:
-; FMF-NEXT: xssubsp 0, 1, 2
-; FMF-NEXT: xxlxor 13, 13, 13
-; FMF-NEXT: xssubsp 1, 13, 0
+; FMF-NEXT: xssubsp 1, 2, 1
; FMF-NEXT: blr
;
; GLOBAL-LABEL: fneg_fsub_nozeros_1:
; GLOBAL: # %bb.0:
-; GLOBAL-NEXT: xssubsp 0, 1, 2
-; GLOBAL-NEXT: xxlxor 13, 13, 13
-; GLOBAL-NEXT: xssubsp 1, 13, 0
+; GLOBAL-NEXT: xssubsp 1, 2, 1
; GLOBAL-NEXT: blr
%neg = fsub float %x, %y
- %add = fsub float 0.0, %neg
+ %add = fsub nsz float 0.0, %neg
ret float %add
}
+
Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4049,10 +4049,10 @@
break;
case ISD::FNEG:
// -(X-Y) -> (Y-X) is unsafe because when X==Y, -0.0 != +0.0
- if (getTarget().Options.UnsafeFPMath && OpOpcode == ISD::FSUB)
- // FIXME: FNEG has no fast-math-flags to propagate; use the FSUB's flags?
+ if ((getTarget().Options.UnsafeFPMath || Flags.hasNoSignedZeros()) &&
+ OpOpcode == ISD::FSUB)
return getNode(ISD::FSUB, DL, VT, Operand.getOperand(1),
- Operand.getOperand(0), Operand.getNode()->getFlags());
+ Operand.getOperand(0), Flags);
if (OpOpcode == ISD::FNEG) // --X -> X
return Operand.getOperand(0);
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47389.150019.patch
Type: text/x-patch
Size: 2363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180605/64c0f7ec/attachment.bin>
More information about the llvm-commits
mailing list