[PATCH] D48180: updating isNegatibleForFree and GetNegatedExpression with fmf for fadd
Michael Berg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 14 11:53:07 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334753: updating isNegatibleForFree and GetNegatedExpression with fmf for fadd (authored by mcberg2017, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D48180?vs=151373&id=151394#toc
Repository:
rL LLVM
https://reviews.llvm.org/D48180
Files:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/test/CodeGen/X86/fp-fold.ll
Index: llvm/trunk/test/CodeGen/X86/fp-fold.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/fp-fold.ll
+++ llvm/trunk/test/CodeGen/X86/fp-fold.ll
@@ -62,6 +62,17 @@
ret float %r
}
+define float @fsub_neg_x_y(float %x, float %y) {
+; ANY-LABEL: fsub_neg_x_y:
+; ANY: # %bb.0:
+; ANY-NEXT: subss %xmm0, %xmm1
+; ANY-NEXT: movaps %xmm1, %xmm0
+; ANY-NEXT: retq
+ %neg = fsub nsz float 0.0, %x
+ %r = fadd nsz float %neg, %y
+ ret float %r
+}
+
define float @fsub_negzero(float %x) {
; STRICT-LABEL: fsub_negzero:
; STRICT: # %bb.0:
Index: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -704,8 +704,8 @@
TLI.isFPImmLegal(neg(cast<ConstantFPSDNode>(Op)->getValueAPF()), VT);
}
case ISD::FADD:
- // FIXME: determine better conditions for this xform.
- if (!Options->UnsafeFPMath) return 0;
+ if (!Options->UnsafeFPMath && !Flags.hasNoSignedZeros())
+ return 0;
// After operation legalization, it might not be legal to create new FSUBs.
if (LegalOperations && !TLI.isOperationLegalOrCustom(ISD::FSUB, VT))
@@ -766,8 +766,7 @@
return DAG.getConstantFP(V, SDLoc(Op), Op.getValueType());
}
case ISD::FADD:
- // FIXME: determine better conditions for this xform.
- assert(Options.UnsafeFPMath);
+ assert(Options.UnsafeFPMath || Flags.hasNoSignedZeros());
// fold (fneg (fadd A, B)) -> (fsub (fneg A), B)
if (isNegatibleForFree(Op.getOperand(0), LegalOperations,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48180.151394.patch
Type: text/x-patch
Size: 1698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180614/11d33ed1/attachment.bin>
More information about the llvm-commits
mailing list