-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MLIR][CF] Avoid collapsing blocks which participate in cycles #160783
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
Merged
+158
−2
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aed78e6
[MLIR][CF] Avoid collapsing blocks which participate in cycles (#159743)
benwu25 a7c8f61
[MLIR][CF] Update control-flow-cycles test (#159743)
benwu25 35ac930
Merge branch 'main' into main
benwu25 3c8e0e1
[MLIR][CF] Fix canonicalizer regression with 1-block cycle (#159743)
benwu25 e051038
Merge branch 'main' into main
benwu25 4250c1d
[MLIR][CF] Use a DenseSet to detect more cycles (#159743)
benwu25 d6f7526
Merge branch 'main' into main
benwu25 6357614
[MLIR][CF] Bail out of collapseBranch when any cycle is detected (#15…
benwu25 44d52d3
Merge branch 'main' into main
benwu25 e8135aa
[MLIR][CF] Do not bail out early in collapseBranch to avoid regressio…
benwu25 63e77da
Merge branch 'main' into main
benwu25 9c27d37
[MLIR][CF] Update broken test (#159743)
benwu25 a4ae338
Merge branch 'main' into main
benwu25 13dfab5
[MLIR][CF] Abort collapseBranch for any cycle (#159743)
benwu25 d2a47c6
Merge branch 'main' into main
benwu25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it possible that this
while
loop runs into an endless loop? E.g.:Assuming that we call
collapseBranch(A, ...)
.I feel like
nextBranchDest == successor
is not sufficient and we need aDenseSet<Block *> visited
instead?Uh oh!
There was an error while loading. Please reload this page.
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 see your argument, and weirdly enough, I have already written this testcase (
@delayed_3_cycle
). I think thatA -> B -> C
is first canonicalized as justC
by a few calls tosimplifyBrToBlockWithSinglePred
, so then when we collapse onC
it somehow works out.However, if
B
has another predecessor, maybe the loop will be broken. Will look into that soon.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.
Here's an example that gets into an endless loop.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, I think a
DenseSet
will be the right tool here. I have added changes to employ one for cycle detection and new tests which require it.