From: Craig Topper Date: Mon, 13 May 2019 22:17:13 +0000 (+0000) Subject: [X86] Use ISD::MERGE_VALUES to return from lowerAtomicArith instead of calling Replac... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5e469b3b8c9bda3f6696244fd8625c4c39305d0;p=llvm [X86] Use ISD::MERGE_VALUES to return from lowerAtomicArith instead of calling ReplaceAllUsesOfValueWith and returning SDValue(). Returning SDValue() makes the caller think that nothing happened and it will end up executing the Expand path. This generates extra nodes that will need to be pruned as dead code. Returning an ISD::MERGE_VALUES will tell the caller that we'd like to make a change and it will take care of replacing uses. This will prevent falling into the Expand path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360627 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 65f3af3f544..3133ddd2a82 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -26404,13 +26404,17 @@ static SDValue lowerAtomicArith(SDValue N, SelectionDAG &DAG, // traffic. This assumes that stack locations are very likely to be // accessed only by the owning thread. SDValue NewChain = emitLockedStackOp(DAG, Subtarget, Chain, DL); - DAG.ReplaceAllUsesOfValueWith(N.getValue(1), NewChain); - return SDValue(); + assert(!N->hasAnyUseOfValue(0)); + // NOTE: The getUNDEF is needed to give something for the unused result 0. + return DAG.getNode(ISD::MERGE_VALUES, DL, N->getVTList(), + DAG.getUNDEF(VT), NewChain); } // MEMBARRIER is a compiler barrier; it codegens to a no-op. SDValue NewChain = DAG.getNode(X86ISD::MEMBARRIER, DL, MVT::Other, Chain); - DAG.ReplaceAllUsesOfValueWith(N.getValue(1), NewChain); - return SDValue(); + assert(!N->hasAnyUseOfValue(0)); + // NOTE: The getUNDEF is needed to give something for the unused result 0. + return DAG.getNode(ISD::MERGE_VALUES, DL, N->getVTList(), + DAG.getUNDEF(VT), NewChain); } SDValue LockOp = lowerAtomicArithWithLOCK(N, DAG, Subtarget);