[llvm] r340853 - [DAGCombine] Rework MERGE_VALUES to inline in single pass. NFCI.

Nirav Dave via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 28 11:13:26 PDT 2018


Author: niravd
Date: Tue Aug 28 11:13:26 2018
New Revision: 340853

URL: http://llvm.org/viewvc/llvm-project?rev=340853&view=rev
Log:
[DAGCombine] Rework MERGE_VALUES to inline in single pass. NFCI.

Avoid hyperlinear cost of inlining MERGE_VALUE node by constructing
temporary vector and doing a single replacement.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=340853&r1=340852&r2=340853&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Aug 28 11:13:26 2018
@@ -1859,8 +1859,11 @@ SDValue DAGCombiner::visitMERGE_VALUES(S
   // can be tried again once they have new operands.
   AddUsersToWorklist(N);
   do {
+    // Do as a single replacement to avoid rewalking use lists.
+    SmallVector<SDValue, 8> Ops;
     for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
-      DAG.ReplaceAllUsesOfValueWith(SDValue(N, i), N->getOperand(i));
+      Ops.push_back(N->getOperand(i));
+    DAG.ReplaceAllUsesWith(N, Ops.data());
   } while (!N->use_empty());
   deleteAndRecombine(N);
   return SDValue(N, 0);   // Return N so it doesn't get rechecked!




More information about the llvm-commits mailing list