Skip to content

Commit 00d383e

Browse files
authored
[DAGCombiner] Limit steps in shouldCombineToPostInc (#116030)
Currently the function will walk the entire DAG to find other candidates to perform a post-inc store. This leads to very long compilation times on large functions. Added a MaxSteps limit to avoid this, which is also aligned to how hasPredecessorHelper is used elsewhere in the code.
1 parent a232600 commit 00d383e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ static cl::opt<bool> EnableVectorFCopySignExtendRound(
149149
cl::desc(
150150
"Enable merging extends and rounds into FCOPYSIGN on vector types"));
151151

152+
static cl::opt<unsigned int>
153+
MaxSteps("has-predecessor-max-steps", cl::Hidden, cl::init(8192),
154+
cl::desc("DAG combiner limit number of steps when searching DAG "
155+
"for predecessor nodes"));
156+
152157
namespace {
153158

154159
class DAGCombiner {
@@ -18911,7 +18916,6 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
1891118916
// can be folded with this one. We should do this to avoid having to keep
1891218917
// a copy of the original base pointer.
1891318918
SmallVector<SDNode *, 16> OtherUses;
18914-
constexpr unsigned int MaxSteps = 8192;
1891518919
if (isa<ConstantSDNode>(Offset))
1891618920
for (SDNode::use_iterator UI = BasePtr->use_begin(),
1891718921
UE = BasePtr->use_end();
@@ -19089,7 +19093,7 @@ static bool shouldCombineToPostInc(SDNode *N, SDValue Ptr, SDNode *PtrUse,
1908919093
IsMasked, OtherPtr, TLI)) {
1909019094
SmallVector<const SDNode *, 2> Worklist;
1909119095
Worklist.push_back(Use);
19092-
if (SDNode::hasPredecessorHelper(N, Visited, Worklist))
19096+
if (SDNode::hasPredecessorHelper(N, Visited, Worklist, MaxSteps))
1909319097
return false;
1909419098
}
1909519099
}
@@ -19130,7 +19134,6 @@ static SDNode *getPostIndexedLoadStoreOp(SDNode *N, bool &IsLoad,
1913019134
// Check for #2.
1913119135
SmallPtrSet<const SDNode *, 32> Visited;
1913219136
SmallVector<const SDNode *, 8> Worklist;
19133-
constexpr unsigned int MaxSteps = 8192;
1913419137
// Ptr is predecessor to both N and Op.
1913519138
Visited.insert(Ptr.getNode());
1913619139
Worklist.push_back(N);

0 commit comments

Comments
 (0)