mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 11:33:24 +02:00
Use local variable in visitFADD. No functional change.
llvm-svn: 216623
This commit is contained in:
parent
7e51cfaccc
commit
df00ebc59f
@ -6548,6 +6548,7 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
|
|||||||
ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
|
||||||
ConstantFPSDNode *N1CFP = dyn_cast<ConstantFPSDNode>(N1);
|
ConstantFPSDNode *N1CFP = dyn_cast<ConstantFPSDNode>(N1);
|
||||||
EVT VT = N->getValueType(0);
|
EVT VT = N->getValueType(0);
|
||||||
|
const TargetOptions *Options = &DAG.getTarget().Options;
|
||||||
|
|
||||||
// fold vector ops
|
// fold vector ops
|
||||||
if (VT.isVector()) {
|
if (VT.isVector()) {
|
||||||
@ -6562,22 +6563,21 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
|
|||||||
if (N0CFP && !N1CFP)
|
if (N0CFP && !N1CFP)
|
||||||
return DAG.getNode(ISD::FADD, SDLoc(N), VT, N1, N0);
|
return DAG.getNode(ISD::FADD, SDLoc(N), VT, N1, N0);
|
||||||
// fold (fadd A, 0) -> A
|
// fold (fadd A, 0) -> A
|
||||||
if (DAG.getTarget().Options.UnsafeFPMath && N1CFP &&
|
if (Options->UnsafeFPMath && N1CFP && N1CFP->getValueAPF().isZero())
|
||||||
N1CFP->getValueAPF().isZero())
|
|
||||||
return N0;
|
return N0;
|
||||||
// fold (fadd A, (fneg B)) -> (fsub A, B)
|
// fold (fadd A, (fneg B)) -> (fsub A, B)
|
||||||
if ((!LegalOperations || TLI.isOperationLegalOrCustom(ISD::FSUB, VT)) &&
|
if ((!LegalOperations || TLI.isOperationLegalOrCustom(ISD::FSUB, VT)) &&
|
||||||
isNegatibleForFree(N1, LegalOperations, TLI, &DAG.getTarget().Options) == 2)
|
isNegatibleForFree(N1, LegalOperations, TLI, Options) == 2)
|
||||||
return DAG.getNode(ISD::FSUB, SDLoc(N), VT, N0,
|
return DAG.getNode(ISD::FSUB, SDLoc(N), VT, N0,
|
||||||
GetNegatedExpression(N1, DAG, LegalOperations));
|
GetNegatedExpression(N1, DAG, LegalOperations));
|
||||||
// fold (fadd (fneg A), B) -> (fsub B, A)
|
// fold (fadd (fneg A), B) -> (fsub B, A)
|
||||||
if ((!LegalOperations || TLI.isOperationLegalOrCustom(ISD::FSUB, VT)) &&
|
if ((!LegalOperations || TLI.isOperationLegalOrCustom(ISD::FSUB, VT)) &&
|
||||||
isNegatibleForFree(N0, LegalOperations, TLI, &DAG.getTarget().Options) == 2)
|
isNegatibleForFree(N0, LegalOperations, TLI, Options) == 2)
|
||||||
return DAG.getNode(ISD::FSUB, SDLoc(N), VT, N1,
|
return DAG.getNode(ISD::FSUB, SDLoc(N), VT, N1,
|
||||||
GetNegatedExpression(N0, DAG, LegalOperations));
|
GetNegatedExpression(N0, DAG, LegalOperations));
|
||||||
|
|
||||||
// If allowed, fold (fadd (fadd x, c1), c2) -> (fadd x, (fadd c1, c2))
|
// If allowed, fold (fadd (fadd x, c1), c2) -> (fadd x, (fadd c1, c2))
|
||||||
if (DAG.getTarget().Options.UnsafeFPMath && N1CFP &&
|
if (Options->UnsafeFPMath && N1CFP &&
|
||||||
N0.getOpcode() == ISD::FADD && N0.getNode()->hasOneUse() &&
|
N0.getOpcode() == ISD::FADD && N0.getNode()->hasOneUse() &&
|
||||||
isa<ConstantFPSDNode>(N0.getOperand(1)))
|
isa<ConstantFPSDNode>(N0.getOperand(1)))
|
||||||
return DAG.getNode(ISD::FADD, SDLoc(N), VT, N0.getOperand(0),
|
return DAG.getNode(ISD::FADD, SDLoc(N), VT, N0.getOperand(0),
|
||||||
@ -6596,20 +6596,19 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
|
|||||||
bool AllowNewFpConst = (Level < AfterLegalizeDAG);
|
bool AllowNewFpConst = (Level < AfterLegalizeDAG);
|
||||||
|
|
||||||
// If allow, fold (fadd (fneg x), x) -> 0.0
|
// If allow, fold (fadd (fneg x), x) -> 0.0
|
||||||
if (AllowNewFpConst && DAG.getTarget().Options.UnsafeFPMath &&
|
if (AllowNewFpConst && Options->UnsafeFPMath &&
|
||||||
N0.getOpcode() == ISD::FNEG && N0.getOperand(0) == N1)
|
N0.getOpcode() == ISD::FNEG && N0.getOperand(0) == N1)
|
||||||
return DAG.getConstantFP(0.0, VT);
|
return DAG.getConstantFP(0.0, VT);
|
||||||
|
|
||||||
// If allow, fold (fadd x, (fneg x)) -> 0.0
|
// If allow, fold (fadd x, (fneg x)) -> 0.0
|
||||||
if (AllowNewFpConst && DAG.getTarget().Options.UnsafeFPMath &&
|
if (AllowNewFpConst && Options->UnsafeFPMath &&
|
||||||
N1.getOpcode() == ISD::FNEG && N1.getOperand(0) == N0)
|
N1.getOpcode() == ISD::FNEG && N1.getOperand(0) == N0)
|
||||||
return DAG.getConstantFP(0.0, VT);
|
return DAG.getConstantFP(0.0, VT);
|
||||||
|
|
||||||
// In unsafe math mode, we can fold chains of FADD's of the same value
|
// In unsafe math mode, we can fold chains of FADD's of the same value
|
||||||
// into multiplications. This transform is not safe in general because
|
// into multiplications. This transform is not safe in general because
|
||||||
// we are reducing the number of rounding steps.
|
// we are reducing the number of rounding steps.
|
||||||
if (DAG.getTarget().Options.UnsafeFPMath &&
|
if (Options->UnsafeFPMath && TLI.isOperationLegalOrCustom(ISD::FMUL, VT) &&
|
||||||
TLI.isOperationLegalOrCustom(ISD::FMUL, VT) &&
|
|
||||||
!N0CFP && !N1CFP) {
|
!N0CFP && !N1CFP) {
|
||||||
if (N0.getOpcode() == ISD::FMUL) {
|
if (N0.getOpcode() == ISD::FMUL) {
|
||||||
ConstantFPSDNode *CFP00 = dyn_cast<ConstantFPSDNode>(N0.getOperand(0));
|
ConstantFPSDNode *CFP00 = dyn_cast<ConstantFPSDNode>(N0.getOperand(0));
|
||||||
@ -6732,8 +6731,7 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FADD -> FMA combines:
|
// FADD -> FMA combines:
|
||||||
if ((DAG.getTarget().Options.AllowFPOpFusion == FPOpFusion::Fast ||
|
if ((Options->AllowFPOpFusion == FPOpFusion::Fast || Options->UnsafeFPMath) &&
|
||||||
DAG.getTarget().Options.UnsafeFPMath) &&
|
|
||||||
DAG.getTarget()
|
DAG.getTarget()
|
||||||
.getSubtargetImpl()
|
.getSubtargetImpl()
|
||||||
->getTargetLowering()
|
->getTargetLowering()
|
||||||
|
Loading…
Reference in New Issue
Block a user