1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

updating isNegatibleForFree and GetNegatedExpression with fmf for fadd

Summary:  A FMF constraint is added to FADD with unsafe still available as the fallback

Reviewers: spatel, wristow, arsenm, hfinkel

Reviewed By: spatel

Subscribers: wdng

Differential Revision: https://reviews.llvm.org/D48180

llvm-svn: 334753
This commit is contained in:
Michael Berg 2018-06-14 18:48:31 +00:00
parent 219c563769
commit c2f9b2d826
2 changed files with 14 additions and 4 deletions

View File

@ -704,8 +704,8 @@ static char isNegatibleForFree(SDValue Op, bool LegalOperations,
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 @@ static SDValue GetNegatedExpression(SDValue Op, SelectionDAG &DAG,
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,

View File

@ -62,6 +62,17 @@ define float @fsub_self(float %x) {
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: