[llvm] r360171 - [DAGCombiner] Avoid creating large tokenfactors in visitTokenFactor

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 09:47:27 PDT 2019


Author: fhahn
Date: Tue May  7 09:47:27 2019
New Revision: 360171

URL: http://llvm.org/viewvc/llvm-project?rev=360171&view=rev
Log:
[DAGCombiner] Avoid creating large tokenfactors in visitTokenFactor

When simplifying TokenFactors, we potentially iterate over all
operands of a large number of TokenFactors. This causes quadratic
compile times in some cases and the large token factors cause additional
scalability problems elsewhere.

This patch adds some limits to the number of nodes explored for the
cases mentioned above.

Reviewers: niravd, spatel, craig.topper

Reviewed By: niravd

Differential Revision: https://reviews.llvm.org/D61397

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=360171&r1=360170&r2=360171&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue May  7 09:47:27 2019
@@ -1792,8 +1792,9 @@ SDValue DAGCombiner::visitTokenFactor(SD
   TFs.push_back(N);
 
   // Iterate through token factors.  The TFs grows when new token factors are
-  // encountered.
-  for (unsigned i = 0; i < TFs.size(); ++i) {
+  // encountered. Limit number of nodes to inline, to avoid quadratic compile
+  // times.
+  for (unsigned i = 0; i < TFs.size() && Ops.size() <= 2048; ++i) {
     SDNode *TF = TFs[i];
 
     // Check each of the operands.




More information about the llvm-commits mailing list