[PATCH] D62633: Recommit r360171: [DAGCombiner] Avoid creating large tokenfactors in visitTokenFactor.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 30 16:53:32 PDT 2019
fhahn updated this revision to Diff 202334.
fhahn added a comment.
Only add tokenfactors instead of inlining the first TF. Adjust logic for adding
TFs to the worklist accordingly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62633/new/
https://reviews.llvm.org/D62633
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1801,8 +1801,19 @@
// Iterate through token factors. The TFs grows when new token factors are
// encountered.
for (unsigned i = 0; i < TFs.size(); ++i) {
- SDNode *TF = TFs[i];
+ // Limit number of nodes to inline, to avoid quadratic compile times.
+ // We have to add the outstanding tokenfactors to Ops, otherwise we might
+ // drop Ops from the resulting tokenfactor.
+ if (Ops.size() > 5) {
+ for (unsigned j = i; j < TFs.size(); j++)
+ Ops.emplace_back(TFs[j], 0);
+ // Drop unprocessed tokenfactors from TFs, so we do not add them to the
+ // combiner worklist later.
+ TFs.resize(i);
+ break;
+ }
+ SDNode *TF = TFs[i];
// Check each of the operands.
for (const SDValue &Op : TF->op_values()) {
switch (Op.getOpcode()) {
@@ -1816,8 +1827,6 @@
if (Op.hasOneUse() && !is_contained(TFs, Op.getNode())) {
// Queue up for processing.
TFs.push_back(Op.getNode());
- // Clean up in case the token factor is removed.
- AddToWorklist(Op.getNode());
Changed = true;
break;
}
@@ -1834,6 +1843,11 @@
}
}
+ // Re-visit inlined tokenfactors, to clean them up in case they have been
+ // removed. Skip the first tokenfacto, as this is the current node.
+ for (unsigned i = 1, e = TFs.size(); i < e ; i++)
+ AddToWorklist(TFs[i]);
+
// Remove Nodes that are chained to another node in the list. Do so
// by walking up chains breath-first stopping when we've seen
// another operand. In general we must climb to the EntryNode, but we can exit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62633.202334.patch
Type: text/x-patch
Size: 1845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/a51106ca/attachment.bin>
More information about the llvm-commits
mailing list