-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DAGCombiner] Limit steps in shouldCombineToPostInc #116030
[DAGCombiner] Limit steps in shouldCombineToPostInc #116030
Conversation
@llvm/pr-subscribers-llvm-selectiondag Author: Jonathan Cohen (jcohen-apple) ChangesCurrently 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. Full diff: https://github.com/llvm/llvm-project/pull/116030.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6059229cd6d9a4..cc51aed40003f0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -19089,7 +19089,8 @@ static bool shouldCombineToPostInc(SDNode *N, SDValue Ptr, SDNode *PtrUse,
IsMasked, OtherPtr, TLI)) {
SmallVector<const SDNode *, 2> Worklist;
Worklist.push_back(Use);
- if (SDNode::hasPredecessorHelper(N, Visited, Worklist))
+ constexpr unsigned int MaxSteps = 8192;
+ if (SDNode::hasPredecessorHelper(N, Visited, Worklist, MaxSteps))
return false;
}
}
|
@@ -19089,7 +19089,8 @@ static bool shouldCombineToPostInc(SDNode *N, SDValue Ptr, SDNode *PtrUse, | |||
IsMasked, OtherPtr, TLI)) { | |||
SmallVector<const SDNode *, 2> Worklist; | |||
Worklist.push_back(Use); | |||
if (SDNode::hasPredecessorHelper(N, Visited, Worklist)) | |||
constexpr unsigned int MaxSteps = 8192; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big number to repeat multiple times. Move these to a common constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to be a hidden cl option in case someone would like to play with it later, and defaulted to 8192. WDYT?
4246b28
to
787ab75
Compare
6eadbbd
to
2790a3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers
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.
2790a3d
to
79a709c
Compare
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.