[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.

llvm-svn: 340853
This commit is contained in:
Nirav Dave 2018-08-28 18:13:26 +00:00
parent 113f2b9058
commit 11e39fb6fb
1 changed files with 4 additions and 1 deletions

View File

@ -1859,8 +1859,11 @@ SDValue DAGCombiner::visitMERGE_VALUES(SDNode *N) {
// can be tried again once they have new operands. // can be tried again once they have new operands.
AddUsersToWorklist(N); AddUsersToWorklist(N);
do { 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) 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()); } while (!N->use_empty());
deleteAndRecombine(N); deleteAndRecombine(N);
return SDValue(N, 0); // Return N so it doesn't get rechecked! return SDValue(N, 0); // Return N so it doesn't get rechecked!