]> granicus.if.org Git - llvm/commitdiff
[X86] Use ISD::MERGE_VALUES to return from lowerAtomicArith instead of calling Replac...
authorCraig Topper <craig.topper@intel.com>
Mon, 13 May 2019 22:17:13 +0000 (22:17 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 13 May 2019 22:17:13 +0000 (22:17 +0000)
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

lib/Target/X86/X86ISelLowering.cpp

index 65f3af3f544f8bd155410684f613f7d63df8cce1..3133ddd2a8286801b695b235ddf85d1880540c17 100644 (file)
@@ -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);