-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Last use analysis & make it an SSA pass (#4686)
# Description ## Problem\* Resolves #4685 ## Summary\* Fixes some issues with the last_use analysis and makes it into a dedicated SSA pass (after all other passes, only on 1 block acir functions). ## Additional Context One case I noticed where we don't make array sets mutable currently is in parallel if branches: ```rs if array[0] == 1 { array[1] = 10; } else { array[1] = 20; } ``` Will produce the IR: ```rs v137 = array_get v0, index u64 0 v138 = eq v137, Field 1 enable_side_effects v138 v139 = array_set v0, index u64 1, value Field 10 v140 = not v138 enable_side_effects v140 v141 = array_set mut v0, index u64 1, value Field 20 enable_side_effects u1 1 ``` Note that with this change we can see the second array_set is mutable and not the first. Fixing this isn't in the scope of this PR but this could be a good future optimization. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** 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.
- Loading branch information
1 parent
8adee4f
commit 941eb5e
Showing
9 changed files
with
154 additions
and
125 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
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.