-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description ## Problem\* `inc_rc` and `dec_rc` instructions can bloat unconstrained code with unneeded rc changes on otherwise immutable arrays. ## Summary\* Adds an optimization pass to remove `inc_rc vN .. dec_rc vN` pairs as long as there are not `array_set` instructions in the same function which may mutate an array of the same type. ## Additional Context I thought of tracking all inc and dec instructions in the function originally but eventually limited it to finding just those in the function's entry block and exit block respectively. The later is the only place we currently issue dec_rc instructions anyway. This restriction greatly simplifies the code since we do not have to merge intermediate results across several blocks, nor do we have to handle inc/dec in loops. This pass applies to both acir and brillig functions since acir functions can still be called in an unconstrained context. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Álvaro Rodríguez <[email protected]>
- Loading branch information
1 parent
6a9ea35
commit dfa5126
Showing
5 changed files
with
379 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
Oops, something went wrong.