[PATCH] D133602: [DAGCombiner] Use HandleSDNode to keep node alive across call to getNegatedExpression.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 22:13:50 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG545affbf79bf: [DAGCombiner] Use HandleSDNode to keep node alive across call to… (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133602/new/
https://reviews.llvm.org/D133602
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/pr57658.ll
Index: llvm/test/CodeGen/X86/pr57658.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/pr57658.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+define <2 x double> @f(<2 x double> %I) {
+; CHECK-LABEL: f:
+; CHECK: # %bb.0: # %BB
+; CHECK-NEXT: movapd {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0]
+; CHECK-NEXT: xorpd %xmm0, %xmm1
+; CHECK-NEXT: mulpd %xmm0, %xmm1
+; CHECK-NEXT: mulpd %xmm0, %xmm1
+; CHECK-NEXT: mulpd %xmm0, %xmm0
+; CHECK-NEXT: mulpd %xmm1, %xmm0
+; CHECK-NEXT: retq
+BB:
+ %F = fneg <2 x double> %I
+ %B3 = fmul <2 x double> %I, %F
+ %B1 = fmul <2 x double> %F, %B3
+ %B2 = fmul <2 x double> %F, %I
+ %B = fmul <2 x double> %B2, %B1
+ ret <2 x double> %B
+}
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15079,12 +15079,14 @@
TargetLowering::NegatibleCost::Expensive;
SDValue NegN0 =
TLI.getNegatedExpression(N0, DAG, LegalOperations, ForCodeSize, CostN0);
- SDValue NegN1 =
- TLI.getNegatedExpression(N1, DAG, LegalOperations, ForCodeSize, CostN1);
- if (NegN0 && NegN1 &&
- (CostN0 == TargetLowering::NegatibleCost::Cheaper ||
- CostN1 == TargetLowering::NegatibleCost::Cheaper))
- return DAG.getNode(ISD::FMUL, DL, VT, NegN0, NegN1);
+ if (NegN0) {
+ HandleSDNode NegN0Handle(NegN0);
+ SDValue NegN1 =
+ TLI.getNegatedExpression(N1, DAG, LegalOperations, ForCodeSize, CostN1);
+ if (NegN1 && (CostN0 == TargetLowering::NegatibleCost::Cheaper ||
+ CostN1 == TargetLowering::NegatibleCost::Cheaper))
+ return DAG.getNode(ISD::FMUL, DL, VT, NegN0, NegN1);
+ }
// fold (fmul X, (select (fcmp X > 0.0), -1.0, 1.0)) -> (fneg (fabs X))
// fold (fmul X, (select (fcmp X > 0.0), 1.0, -1.0)) -> (fabs X)
@@ -15170,12 +15172,14 @@
TargetLowering::NegatibleCost::Expensive;
SDValue NegN0 =
TLI.getNegatedExpression(N0, DAG, LegalOperations, ForCodeSize, CostN0);
- SDValue NegN1 =
- TLI.getNegatedExpression(N1, DAG, LegalOperations, ForCodeSize, CostN1);
- if (NegN0 && NegN1 &&
- (CostN0 == TargetLowering::NegatibleCost::Cheaper ||
- CostN1 == TargetLowering::NegatibleCost::Cheaper))
- return DAG.getNode(ISD::FMA, DL, VT, NegN0, NegN1, N2);
+ if (NegN0) {
+ HandleSDNode NegN0Handle(NegN0);
+ SDValue NegN1 =
+ TLI.getNegatedExpression(N1, DAG, LegalOperations, ForCodeSize, CostN1);
+ if (NegN1 && (CostN0 == TargetLowering::NegatibleCost::Cheaper ||
+ CostN1 == TargetLowering::NegatibleCost::Cheaper))
+ return DAG.getNode(ISD::FMA, DL, VT, NegN0, NegN1, N2);
+ }
// FIXME: use fast math flags instead of Options.UnsafeFPMath
if (Options.UnsafeFPMath) {
@@ -15473,12 +15477,14 @@
TargetLowering::NegatibleCost::Expensive;
SDValue NegN0 =
TLI.getNegatedExpression(N0, DAG, LegalOperations, ForCodeSize, CostN0);
- SDValue NegN1 =
- TLI.getNegatedExpression(N1, DAG, LegalOperations, ForCodeSize, CostN1);
- if (NegN0 && NegN1 &&
- (CostN0 == TargetLowering::NegatibleCost::Cheaper ||
- CostN1 == TargetLowering::NegatibleCost::Cheaper))
- return DAG.getNode(ISD::FDIV, SDLoc(N), VT, NegN0, NegN1);
+ if (NegN0) {
+ HandleSDNode NegN0Handle(NegN0);
+ SDValue NegN1 =
+ TLI.getNegatedExpression(N1, DAG, LegalOperations, ForCodeSize, CostN1);
+ if (NegN1 && (CostN0 == TargetLowering::NegatibleCost::Cheaper ||
+ CostN1 == TargetLowering::NegatibleCost::Cheaper))
+ return DAG.getNode(ISD::FDIV, SDLoc(N), VT, NegN0, NegN1);
+ }
return SDValue();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133602.459252.patch
Type: text/x-patch
Size: 3903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220910/c2fda2c4/attachment.bin>
More information about the llvm-commits
mailing list