[PATCH] D59795: [DAGCombine] Improve Lifetime node chains.
Nirav Dave via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 10:55:22 PDT 2019
niravd updated this revision to Diff 192682.
niravd added a comment.
Now that lifetime node hashing and TokenFactor cleanup has happened, factor out Dead Store improvements as they are no longer needed to prevent regressions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59795/new/
https://reviews.llvm.org/D59795
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/swap.ll
Index: llvm/test/CodeGen/X86/swap.ll
===================================================================
--- llvm/test/CodeGen/X86/swap.ll
+++ llvm/test/CodeGen/X86/swap.ll
@@ -94,7 +94,6 @@
; AA-LABEL: twoallocs:
; AA: # %bb.0: # %entry
; AA-NEXT: vmovups (%rdi), %xmm0
-; AA-NEXT: vmovaps %xmm0, -{{[0-9]+}}(%rsp)
; AA-NEXT: vmovups %xmm0, (%rsi)
; AA-NEXT: retq
entry:
@@ -125,7 +124,6 @@
; AA-LABEL: onealloc_readback_1:
; AA: # %bb.0: # %entry
; AA-NEXT: vmovups (%rsi), %xmm0
-; AA-NEXT: vmovaps %xmm0, -{{[0-9]+}}(%rsp)
; AA-NEXT: vmovups %xmm0, (%rdi)
; AA-NEXT: retq
entry:
@@ -155,7 +153,6 @@
; AA-LABEL: onealloc_readback_2:
; AA: # %bb.0: # %entry
; AA-NEXT: vmovups (%rsi), %xmm0
-; AA-NEXT: vmovaps %xmm0, -{{[0-9]+}}(%rsp)
; AA-NEXT: vmovups %xmm0, (%rdi)
; AA-NEXT: retq
entry:
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -384,6 +384,10 @@
SDValue replaceStoreOfFPConstant(StoreSDNode *ST);
SDValue visitSTORE(SDNode *N);
+
+ SDValue ImproveLifetimeNodeChain(SDNode *N);
+
+ SDValue visitLIFETIME_START(SDNode *N);
SDValue visitLIFETIME_END(SDNode *N);
SDValue visitINSERT_VECTOR_ELT(SDNode *N);
SDValue visitEXTRACT_VECTOR_ELT(SDNode *N);
@@ -1604,6 +1608,7 @@
case ISD::MLOAD: return visitMLOAD(N);
case ISD::MSCATTER: return visitMSCATTER(N);
case ISD::MSTORE: return visitMSTORE(N);
+ case ISD::LIFETIME_START: return visitLIFETIME_START(N);
case ISD::LIFETIME_END: return visitLIFETIME_END(N);
case ISD::FP_TO_FP16: return visitFP_TO_FP16(N);
case ISD::FP16_TO_FP: return visitFP16_TO_FP(N);
@@ -15645,7 +15650,32 @@
return ReduceLoadOpStoreWidth(N);
}
+SDValue DAGCombiner::ImproveLifetimeNodeChain(SDNode *N) {
+ auto Chain = N->getOperand(0);
+ auto NewChain = FindBetterChain(N, Chain);
+ if (NewChain != Chain) {
+ SDNode *N2 = DAG.UpdateNodeOperands(N, NewChain, N->getOperand(1));
+ // Make sure users of new N still depend on Chain
+ auto TF = DAG.getNode(ISD::TokenFactor, SDLoc(N2), MVT::Other, Chain,
+ SDValue(N2, 0));
+ DAG.ReplaceAllUsesOfValueWith(SDValue(N2, 0), TF);
+ AddToWorklist(DAG.UpdateNodeOperands(TF.getNode(), Chain, SDValue(N2, 0)));
+ AddToWorklist(N2);
+ return SDValue(N, 0);
+ }
+ return SDValue();
+}
+
+SDValue DAGCombiner::visitLIFETIME_START(SDNode *N) {
+ if (SDValue V = ImproveLifetimeNodeChain(N))
+ return V;
+ return SDValue();
+}
+
SDValue DAGCombiner::visitLIFETIME_END(SDNode *N) {
+ if (SDValue V = ImproveLifetimeNodeChain(N))
+ return V;
+
const auto *LifetimeEnd = cast<LifetimeSDNode>(N);
if (!LifetimeEnd->hasOffset())
return SDValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59795.192682.patch
Type: text/x-patch
Size: 2952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190328/6c6838f6/attachment.bin>
More information about the llvm-commits
mailing list