Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sync from aztec-packages #6634

Merged
merged 12 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b8bace9a00c3a8eb93f42682e8cbfa351fc5238c
1bfc15e08873a1f0f3743e259f418b70426b3f25
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 12 additions & 24 deletions compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl<'brillig> Context<'brillig> {
block = dominator;
}
}
}
};

let new_results =
// First try to inline a call to a brillig function with all constant arguments.
Expand Down Expand Up @@ -498,7 +498,6 @@ impl<'brillig> Context<'brillig> {
block: BasicBlockId,
) -> Option<CacheResult> {
let results_for_instruction = self.cached_instruction_results.get(instruction)?;

let predicate = self.use_constraint_info && instruction.requires_acir_gen_predicate(dfg);
let predicate = predicate.then_some(side_effects_enabled_var);

Expand Down Expand Up @@ -1004,32 +1003,22 @@ mod test {
// Regression for #4600
#[test]
fn array_get_regression() {
// fn main f0 {
// b0(v0: u1, v1: u64):
// enable_side_effects_if v0
// v2 = make_array [Field 0, Field 1]
// v3 = array_get v2, index v1
// v4 = not v0
// enable_side_effects_if v4
// v5 = array_get v2, index v1
// }
//
// We want to make sure after constant folding both array_gets remain since they are
// under different enable_side_effects_if contexts and thus one may be disabled while
// the other is not. If one is removed, it is possible e.g. v4 is replaced with v2 which
// is disabled (only gets from index 0) and thus returns the wrong result.
let src = "
acir(inline) fn main f0 {
b0(v0: u1, v1: u64):
enable_side_effects v0
v4 = make_array [Field 0, Field 1] : [Field; 2]
v5 = array_get v4, index v1 -> Field
v6 = not v0
enable_side_effects v6
v7 = array_get v4, index v1 -> Field
return
}
";
acir(inline) fn main f0 {
b0(v0: u1, v1: u64):
enable_side_effects v0
v4 = make_array [Field 0, Field 1] : [Field; 2]
v5 = array_get v4, index v1 -> Field
v6 = not v0
enable_side_effects v6
v7 = array_get v4, index v1 -> Field
return
}
";
let ssa = Ssa::from_str(src).unwrap();

// Expected output is unchanged
Expand Down Expand Up @@ -1096,7 +1085,6 @@ mod test {
// v5 = call keccakf1600(v1)
// v6 = call keccakf1600(v2)
// }
//
// Here we're checking a situation where two identical arrays are being initialized twice and being assigned separate `ValueId`s.
// This would result in otherwise identical instructions not being deduplicated.
let main_id = Id::test_new(0);
Expand Down
6 changes: 1 addition & 5 deletions compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ impl<'f> Context<'f> {
// If this is not a separate variable, clippy gets confused and says the to_vec is
// unnecessary, when removing it actually causes an aliasing/mutability error.
let instructions = self.inserter.function.dfg[block].instructions().to_vec();

for instruction in instructions.iter() {
if self.is_no_predicate(no_predicates, instruction) {
// disable side effect for no_predicate functions
Expand Down Expand Up @@ -637,10 +636,6 @@ impl<'f> Context<'f> {

/// If we are currently in a branch, we need to modify constrain instructions
/// to multiply them by the branch's condition (see optimization #1 in the module comment).
///
/// `previous_allocate_result` should only be set to the result of an allocate instruction
/// if that instruction was the instruction immediately previous to this one - if there are
/// any instructions in between it should be None.
fn handle_instruction_side_effects(
&mut self,
instruction: Instruction,
Expand Down Expand Up @@ -1282,6 +1277,7 @@ mod test {
fn should_not_merge_incorrectly_to_false() {
// Regression test for #1792
// Tests that it does not simplify a true constraint an always-false constraint

let src = "
acir(inline) fn main f0 {
b0(v0: [u8; 2]):
Expand Down
Loading