[NFC] [DAGCombiner] Remove unnecessary negation in visitFNEG

In visitFNEG of DAGCombiner, the folding of (fneg (fsub c, x)) is
redundant since getNegatedExpression already handles it.
This commit is contained in:
Qiu Chaofan 2020-09-01 00:35:01 +08:00
parent 102583c8b4
commit 9b5b508e71
2 changed files with 13 additions and 16 deletions

View File

@ -14022,22 +14022,6 @@ SDValue DAGCombiner::visitFNEG(SDNode *N) {
}
}
// (fneg (fmul c, x)) -> (fmul -c, x)
if (N0.getOpcode() == ISD::FMUL &&
(N0.getNode()->hasOneUse() || !TLI.isFNegFree(VT))) {
ConstantFPSDNode *CFP1 = dyn_cast<ConstantFPSDNode>(N0.getOperand(1));
if (CFP1) {
APFloat CVal = CFP1->getValueAPF();
CVal.changeSign();
if (LegalDAG && (TLI.isFPImmLegal(CVal, VT, ForCodeSize) ||
TLI.isOperationLegal(ISD::ConstantFP, VT)))
return DAG.getNode(
ISD::FMUL, SDLoc(N), VT, N0.getOperand(0),
DAG.getNode(ISD::FNEG, SDLoc(N), VT, N0.getOperand(1)),
N0->getFlags());
}
}
return SDValue();
}

View File

@ -56,3 +56,16 @@ define double @fneg_no_ice(float %x) {
%e3 = fmul double %e, %e2
ret double %e3
}
define double @fneg_fmul_const(double %x) {
; CHECK-LABEL: fneg_fmul_const:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lis r3, .LCPI4_0@ha
; CHECK-NEXT: lfd f0, .LCPI4_0@l(r3)
; CHECK-NEXT: fmul f1, f1, f0
; CHECK-NEXT: blr
entry:
%f = fmul double %x, 1.2345
%s = fneg double %f
ret double %s
}