-
Notifications
You must be signed in to change notification settings - Fork 72
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
transformations: Implement control-flow-hoist
#3103
Merged
Merged
Conversation
This file contains 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
PapyChacal
force-pushed
the
emilien/control-flow-hoist
branch
from
August 27, 2024 14:52
338bd41
to
39aaff2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3103 +/- ##
==========================================
- Coverage 89.91% 89.89% -0.02%
==========================================
Files 419 420 +1
Lines 53070 53129 +59
Branches 8226 8237 +11
==========================================
+ Hits 47718 47761 +43
- Misses 4023 4037 +14
- Partials 1329 1331 +2 ☔ View full report in Codecov by Sentry. |
superlopuh
reviewed
Aug 27, 2024
superlopuh
approved these changes
Aug 27, 2024
PapyChacal
force-pushed
the
emilien/control-flow-hoist
branch
from
August 28, 2024 10:38
39aaff2
to
07d9ab6
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on:
A couple of splittable but minor changes:
Just a simple and naive pass hoisting everything from region branches.
Thinking a bit, I realized this is all I missed for some slightly tricky cases to work the way I want in MLIR; see filecheck for more!
In a nutshell, MLIR provides some nice bits already, like
loop-invariant-code-motion
(Get stuff out of loop) andcontrol-flow-sink
(Nest stuff in branches) which are locally okay and smart, but contradict sometimes leading to frustrating things like, to reduce it as much as possible:From the
scf.if
's perspective, one should really keep thearith.muli
nested. What a waste if you compute it and don't take this branch!Thus from the loop's perspective, it's not as easy as hoisting an operation from its body and is not done.
So this pass does a typically-bad thing to help get out of this kind of local-minima frustration. Just naively hoist everything out of the conditionals to expose the loop-invariant bits, and sink the rest back if desired!
It should also help if someone wants to go from branches to precomputation + select, as I remember was a cool shader trick some amount of years ago at least 😋