mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:19:43 +00:00
[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:
parent
102583c8b4
commit
9b5b508e71
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user