-
Notifications
You must be signed in to change notification settings - Fork 293
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
[Arc] Add dominance-aware pass to sink ops and merge scf.if ops #7702
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
fabianschuiki
requested review from
TaoBi22 and
maerhart
and removed request for
maerhart
October 14, 2024 02:40
TaoBi22
approved these changes
Oct 14, 2024
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.
This is super cool! Very cool that this detects and works with non-overlapping side effects too!
fabianschuiki
force-pushed
the
fschuiki/arc-ssacfg-model
branch
from
October 14, 2024 16:34
399dbdc
to
3bf4dc3
Compare
fabianschuiki
force-pushed
the
fschuiki/arc-merge-ifs
branch
from
October 14, 2024 16:59
ab552e4
to
e0068a6
Compare
maerhart
approved these changes
Oct 15, 2024
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.
Awesome work! 🎉
fabianschuiki
force-pushed
the
fschuiki/arc-merge-ifs
branch
from
October 15, 2024 16:45
e0068a6
to
46a9297
Compare
Add the `MergeIfs` pass to the Arc dialect. This pass covers a handful of control flow optimizations that are valuable to pick up after `hw.module`s have been linearized and lowered into `arc.model` ops: - It moves operations closer to their earliest user, if possible sinking them into blocks if all uses are nested in the same block. - It merges adjacent `scf.if` operations with the same condition. - It moves operations in between two `scf.if` operations ahead of the first if op to allow them to be merged. The `MergeIfs` pass can operate on SSACFG regions. It assigns an integer order to each operation and considers that order to determine up to which point operations can be moved without moving beyond their first use and without crossing interfering side-effecting ops. The pass is aware of side-effects, and in particular uses the non-aliasing between `arc.state` and `arc.memory` to track read/write side-effects at a per-state level, which allows for fairly aggressive optimization. Other side-effecting ops act as a hard barrier and will not be moved or moved over. This pass supersedes the very effective `GroupResetsAndEnables` pass we have been using until now. The latter relies on the `LegalizeStateUpdate` pass to run at a later point however, which will be removed in a future PR, thus making this new pass necessary. This is a preparatory step for a later PR that overhauls the LowerState pass. That rewrite will make the `arc.clock_tree` and `arc.passthrough` ops obsolete, which is why they are not present in the tests.
fabianschuiki
force-pushed
the
fschuiki/arc-merge-ifs
branch
from
October 15, 2024 17:18
46a9297
to
ded454f
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.
Add the
MergeIfs
pass to the Arc dialect. This pass covers a handful of control flow optimizations that are valuable to pick up afterhw.module
s have been linearized and lowered intoarc.model
ops:scf.if
operations with the same condition.scf.if
operations ahead of the first if op to allow them to be merged.The
MergeIfs
pass can operate on SSACFG regions. It assigns an integer order to each operation and considers that order to determine up to which point operations can be moved without moving beyond their first use and without crossing interfering side-effecting ops. The pass is aware of side-effects, and in particular uses the non-aliasing betweenarc.state
andarc.memory
to track read/write side-effects at a per-state level, which allows for fairly aggressive optimization. Other side-effecting ops act as a hard barrier and will not be moved or moved over.This pass supersedes the very effective
GroupResetsAndEnables
pass we have been using until now. The latter relies on theLegalizeStateUpdate
pass to run at a later point however, which will be removed in a future PR, thus making this new pass necessary.This is a preparatory step for a later PR that overhauls the LowerState pass. That rewrite will make the
arc.clock_tree
andarc.passthrough
ops obsolete, which is why they are not present in the tests.