Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Arc] Add dominance-aware pass to sink ops and merge scf.if ops
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.
- Loading branch information