Skip to content

Commit 8670986

Browse files
authored
[DAGCombiner] Limit steps in shouldCombineToPostInc
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. rdar://106647280
2 parents 0b869d9 + fca7e10 commit 8670986

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
@@ -150,6 +150,11 @@ static cl::opt<bool> EnableVectorFCopySignExtendRound(
150150
cl::desc(
151151
"Enable merging extends and rounds into FCOPYSIGN on vector types"));
152152

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

155160
class DAGCombiner {
@@ -18518,7 +18523,6 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
1851818523
// can be folded with this one. We should do this to avoid having to keep
1851918524
// a copy of the original base pointer.
1852018525
SmallVector<SDNode *, 16> OtherUses;
18521-
constexpr unsigned int MaxSteps = 8192;
1852218526
if (isa<ConstantSDNode>(Offset))
1852318527
for (SDNode::use_iterator UI = BasePtr->use_begin(),
1852418528
UE = BasePtr->use_end();
@@ -18696,7 +18700,7 @@ static bool shouldCombineToPostInc(SDNode *N, SDValue Ptr, SDNode *PtrUse,
1869618700
IsMasked, OtherPtr, TLI)) {
1869718701
SmallVector<const SDNode *, 2> Worklist;
1869818702
Worklist.push_back(Use);
18699-
if (SDNode::hasPredecessorHelper(N, Visited, Worklist))
18703+
if (SDNode::hasPredecessorHelper(N, Visited, Worklist, MaxSteps))
1870018704
return false;
1870118705
}
1870218706
}
@@ -18737,7 +18741,6 @@ static SDNode *getPostIndexedLoadStoreOp(SDNode *N, bool &IsLoad,
1873718741
// Check for #2.
1873818742
SmallPtrSet<const SDNode *, 32> Visited;
1873918743
SmallVector<const SDNode *, 8> Worklist;
18740-
constexpr unsigned int MaxSteps = 8192;
1874118744
// Ptr is predecessor to both N and Op.
1874218745
Visited.insert(Ptr.getNode());
1874318746
Worklist.push_back(N);

0 commit comments

Comments
 (0)