-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use constraint information to perform constant folding (#4060)
# Description ## Problem\* Resolves #4070 ## Summary\* This PR uses `Instruction::Constrain` to perform simplifications in SSA where one value is swapped for another simpler value due to the fact that the circuit will be unsatisfiable should the two values not be equivalent (because of the `Instruction::Constrain`. A previous implementation of this resulted in the bug #2645. This was because constraints which were only active in certain areas of the code were applied across all of the SSA. This implementation avoids this by using a separate cache for the constrained values for each value of `side_effects_enabled_var`. This means that passing a `Instruction::EnableSideEffects` instruction will "forget" any constraints which aren't currently active. One trouble from this PR is that we now require multiple passes in order to fully simplify the circuit. I've simply added another set of the final 3 passes but we could in future perform extra passes until the SSA stabilises. ## Additional 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.
- Loading branch information
1 parent
fd15052
commit 9a4bf16
Showing
2 changed files
with
117 additions
and
13 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