-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix brillig slowdown when assigning arrays in loops (#4472)
# Description ## Problem\* Resolves #3795 ## Summary\* This is an older version of #4210 which undoes the change in d331ee2 due to a regression #4332. This PR is not yet confirmed to work since I do not have a test case for it! @sirasistant, do you mind seeing if this fixes the regression issue? ## 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\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
5 changed files
with
54 additions
and
2 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
7 changes: 7 additions & 0 deletions
7
test_programs/execution_success/brillig_cow_assign/Nargo.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "brillig_cow_assign" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
2 changes: 2 additions & 0 deletions
2
test_programs/execution_success/brillig_cow_assign/Prover.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
items_to_update = 10 | ||
index = 6 |
23 changes: 23 additions & 0 deletions
23
test_programs/execution_success/brillig_cow_assign/src/main.nr
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
global N = 10; | ||
|
||
unconstrained fn main() { | ||
let mut arr = [0; N]; | ||
let mut mid_change = arr; | ||
|
||
for i in 0..N { | ||
if i == N / 2 { | ||
mid_change = arr; | ||
} | ||
arr[i] = 27; | ||
} | ||
|
||
// Expect: | ||
// arr = [27, 27, 27, 27, 27, 27, 27, 27, 27, 27] | ||
// mid_change = [27, 27, 27, 27, 27, 0, 0, 0, 0, 0] | ||
|
||
let modified_i = N / 2 + 1; | ||
assert_eq(arr[modified_i], 27); | ||
|
||
// Fail here! | ||
assert(mid_change[modified_i] != 27); | ||
} |