[PATCH] D86689: [DAGCombine] Don't delete the node if it has uses immediately
Qing Shan Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 18:11:53 PDT 2020
steven.zhang updated this revision to Diff 288498.
steven.zhang added a comment.
Update test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86689/new/
https://reviews.llvm.org/D86689
Files:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/PowerPC/fneg.ll
Index: llvm/test/CodeGen/PowerPC/fneg.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/fneg.ll
+++ llvm/test/CodeGen/PowerPC/fneg.ll
@@ -39,3 +39,20 @@
%r = call float @llvm.fmuladd.f32(float %negx, float %negy, float %z)
ret float %r
}
+
+; Verify that we didn't hit assertion for this case.
+define double @fneg_no_ice(float %x) {
+; CHECK-LABEL: fneg_no_ice:
+; CHECK: # %bb.0:
+; CHECK-NEXT: lis r3, .LCPI3_0 at ha
+; CHECK-NEXT: lfs f0, .LCPI3_0 at l(r3)
+; CHECK-NEXT: fsubs f0, f0, f1
+; CHECK-NEXT: fmul f1, f0, f0
+; CHECK-NEXT: fmul f1, f0, f1
+; CHECK-NEXT: blr
+ %y = fsub fast float 1.0, %x
+ %e = fpext float %y to double
+ %e2 = fmul double %e, %e
+ %e3 = fmul double %e, %e2
+ ret double %e3
+}
Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5820,15 +5820,17 @@
// Negate the X if its cost is less or equal than Y.
if (NegX && (CostX <= CostY)) {
Cost = CostX;
+ SDValue N = DAG.getNode(ISD::FSUB, DL, VT, NegX, Y, Flags);
RemoveDeadNode(NegY);
- return DAG.getNode(ISD::FSUB, DL, VT, NegX, Y, Flags);
+ return N;
}
// Negate the Y if it is not expensive.
if (NegY) {
Cost = CostY;
+ SDValue N = DAG.getNode(ISD::FSUB, DL, VT, NegY, X, Flags);
RemoveDeadNode(NegX);
- return DAG.getNode(ISD::FSUB, DL, VT, NegY, X, Flags);
+ return N;
}
break;
}
@@ -5865,8 +5867,9 @@
// Negate the X if its cost is less or equal than Y.
if (NegX && (CostX <= CostY)) {
Cost = CostX;
+ SDValue N = DAG.getNode(Opcode, DL, VT, NegX, Y, Flags);
RemoveDeadNode(NegY);
- return DAG.getNode(Opcode, DL, VT, NegX, Y, Flags);
+ return N;
}
// Ignore X * 2.0 because that is expected to be canonicalized to X + X.
@@ -5877,8 +5880,9 @@
// Negate the Y if it is not expensive.
if (NegY) {
Cost = CostY;
+ SDValue N = DAG.getNode(Opcode, DL, VT, X, NegY, Flags);
RemoveDeadNode(NegX);
- return DAG.getNode(Opcode, DL, VT, X, NegY, Flags);
+ return N;
}
break;
}
@@ -5907,15 +5911,17 @@
// Negate the X if its cost is less or equal than Y.
if (NegX && (CostX <= CostY)) {
Cost = std::min(CostX, CostZ);
+ SDValue N = DAG.getNode(Opcode, DL, VT, NegX, Y, NegZ, Flags);
RemoveDeadNode(NegY);
- return DAG.getNode(Opcode, DL, VT, NegX, Y, NegZ, Flags);
+ return N;
}
// Negate the Y if it is not expensive.
if (NegY) {
Cost = std::min(CostY, CostZ);
+ SDValue N = DAG.getNode(Opcode, DL, VT, X, NegY, NegZ, Flags);
RemoveDeadNode(NegX);
- return DAG.getNode(Opcode, DL, VT, X, NegY, NegZ, Flags);
+ return N;
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86689.288498.patch
Type: text/x-patch
Size: 2973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200828/5a719d73/attachment.bin>
More information about the llvm-commits
mailing list