From e3092ab7e52863bea57fe383874d565a3f5ce406 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 21 May 2025 18:55:34 +0000 Subject: [PATCH 1/3] remove the array cache from the inserter, leave reduction of make array repitition in unrolling to hoisting --- .../src/ssa/ir/function_inserter.rs | 91 +-------------- .../src/ssa/opt/normalize_value_ids.rs | 2 +- .../noirc_evaluator/src/ssa/opt/unrolling.rs | 24 +--- .../unrolling_regression_8333/Nargo.toml | 6 + .../unrolling_regression_8333/src/main.nr | 9 ++ .../unrolling_regression_8333/stdout.txt | 1 + .../execute__tests__expanded.snap | 12 ++ ...ig_false_inliner_-9223372036854775808.snap | 105 ++++++++++++++++++ ..._tests__force_brillig_false_inliner_0.snap | 105 ++++++++++++++++++ ...lig_false_inliner_9223372036854775807.snap | 105 ++++++++++++++++++ ...lig_true_inliner_-9223372036854775808.snap | 60 ++++++++++ ...__tests__force_brillig_true_inliner_0.snap | 60 ++++++++++ ...llig_true_inliner_9223372036854775807.snap | 60 ++++++++++ .../execute__tests__stdout.snap | 5 + 14 files changed, 538 insertions(+), 107 deletions(-) create mode 100644 test_programs/execution_success/unrolling_regression_8333/Nargo.toml create mode 100644 test_programs/execution_success/unrolling_regression_8333/src/main.nr create mode 100644 test_programs/execution_success/unrolling_regression_8333/stdout.txt create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__expanded.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_0.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_9223372036854775807.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_0.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_9223372036854775807.snap create mode 100644 tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__stdout.snap diff --git a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs index a87e6590f0f..6cd3d1a3630 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs @@ -1,8 +1,6 @@ use iter_extended::vecmap; use noirc_errors::call_stack::CallStackId; -use crate::ssa::ir::types::Type; - use super::{ basic_block::BasicBlockId, dfg::InsertInstructionResult, @@ -19,26 +17,11 @@ pub(crate) struct FunctionInserter<'f> { pub(crate) function: &'f mut Function, values: HashMap, - - /// Map containing repeat array constants so that we do not initialize a new - /// array unnecessarily. An extra tuple field is included as part of the key to - /// distinguish between array/slice types. - /// - /// This is optional since caching arrays relies on the inserter inserting strictly - /// in control-flow order. Otherwise, if arrays later in the program are cached first, - /// they may be referred to by instructions earlier in the program. - array_cache: Option, - - /// If this pass is loop unrolling, store the block before the loop to optionally - /// hoist any make_array instructions up to after they are retrieved from the `array_cache`. - pre_loop: Option, } -pub(crate) type ArrayCache = HashMap, HashMap>; - impl<'f> FunctionInserter<'f> { pub(crate) fn new(function: &'f mut Function) -> FunctionInserter<'f> { - Self { function, values: HashMap::default(), array_cache: None, pre_loop: None } + Self { function, values: HashMap::default() } } /// Resolves a ValueId to its new, updated value. @@ -120,7 +103,7 @@ impl<'f> FunctionInserter<'f> { &mut self, instruction: Instruction, id: InstructionId, - mut block: BasicBlockId, + block: BasicBlockId, call_stack: CallStackId, ) -> InsertInstructionResult { let results = self.function.dfg.instruction_results(id).to_vec(); @@ -129,85 +112,17 @@ impl<'f> FunctionInserter<'f> { .requires_ctrl_typevars() .then(|| vecmap(&results, |result| self.function.dfg.type_of_value(*result))); - // Large arrays can lead to OOM panics if duplicated from being unrolled in loops. - // To prevent this, try to reuse the same ID for identical arrays instead of inserting - // another MakeArray instruction. Note that this assumes the function inserter is inserting - // in control-flow order. Otherwise we could refer to ValueIds defined later in the program. - let make_array = if let Instruction::MakeArray { elements, typ } = &instruction { - if self.array_is_constant(elements) && self.function.runtime().is_acir() { - if let Some(fetched_value) = self.get_cached_array(elements, typ) { - assert_eq!(results.len(), 1); - self.values.insert(results[0], fetched_value); - return InsertInstructionResult::SimplifiedTo(fetched_value); - } - - // Hoist constant arrays out of the loop and cache their value - if let Some(pre_loop) = self.pre_loop { - block = pre_loop; - } - Some((elements.clone(), typ.clone())) - } else { - None - } - } else { - None - }; - let new_results = self.function.dfg.insert_instruction_and_results( - instruction, + instruction.clone(), block, ctrl_typevars, call_stack, ); - // Cache an array in the fresh_array_cache if array caching is enabled. - // The fresh cache isn't used for deduplication until an external pass confirms we - // pass a sequence point and all blocks that may be before the current insertion point - // are finished. - if let Some((elements, typ)) = make_array { - Self::cache_array(&mut self.array_cache, elements, typ, new_results.first()); - } - Self::insert_new_instruction_results(&mut self.values, &results, &new_results); new_results } - fn get_cached_array(&self, elements: &im::Vector, typ: &Type) -> Option { - self.array_cache.as_ref()?.get(elements)?.get(typ).copied() - } - - fn cache_array( - arrays: &mut Option, - elements: im::Vector, - typ: Type, - result_id: ValueId, - ) { - if let Some(arrays) = arrays { - arrays.entry(elements).or_default().insert(typ, result_id); - } - } - - fn array_is_constant(&self, elements: &im::Vector) -> bool { - elements.iter().all(|element| self.function.dfg.is_constant(*element)) - } - - pub(crate) fn set_array_cache( - &mut self, - new_cache: Option, - pre_loop: BasicBlockId, - ) { - self.array_cache = new_cache; - self.pre_loop = Some(pre_loop); - } - - /// Finish this inserter, returning its array cache merged with the fresh array cache. - /// Since this consumes the inserter this assumes we're at a sequence point where all - /// predecessor blocks to the current block are finished. Since this is true, the fresh - /// array cache can be merged with the existing array cache. - pub(crate) fn into_array_cache(self) -> Option { - self.array_cache - } - /// Modify the values HashMap to remember the mapping between an instruction result's previous /// ValueId (from the source_function) and its new ValueId in the destination function. pub(crate) fn insert_new_instruction_results( diff --git a/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs b/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs index d9b44de9fdb..b90a49397db 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs @@ -178,7 +178,7 @@ impl IdMaps { value @ Value::Instruction { instruction, .. } => { *self.values.get(&old_value).unwrap_or_else(|| { let instruction = &old_function.dfg[*instruction]; - unreachable!("Unmapped value with id {old_value}: {value:?}\n from instruction: {instruction:?}, SSA: {old_function}") + unreachable!("Unmapped value with id {old_value}: {value:?}\n from instruction: {instruction:?}, from function: {}", old_function.id()) }) } diff --git a/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs b/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs index 4826fb4ded3..419df61f75b 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs @@ -33,7 +33,7 @@ use crate::{ dfg::DataFlowGraph, dom::DominatorTree, function::Function, - function_inserter::{ArrayCache, FunctionInserter}, + function_inserter::FunctionInserter, instruction::{Binary, BinaryOp, Instruction, InstructionId, TerminatorInstruction}, integer::IntegerConstant, post_order::PostOrder, @@ -439,21 +439,9 @@ impl Loop { fn unroll(&self, function: &mut Function, cfg: &ControlFlowGraph) -> Result<(), CallStack> { let mut unroll_into = self.get_pre_header(function, cfg)?; let mut jump_value = get_induction_variable(function, unroll_into)?; - let mut array_cache = Some(ArrayCache::default()); - - while let Some(mut context) = self.unroll_header(function, unroll_into, jump_value)? { - // The inserter's array cache must be explicitly enabled. This is to - // confirm that we're inserting in insertion order. This is true here since: - // 1. We have a fresh inserter for each loop - // 2. Each loop is unrolled in iteration order - // - // Within a loop we do not insert in insertion order. This is fine however since the - // array cache is buffered with a separate fresh_array_cache which collects arrays - // but does not deduplicate. When we later call `into_array_cache`, that will merge - // the fresh cache in with the old one so that each iteration of the loop can cache - // from previous iterations but not the current iteration. - context.inserter.set_array_cache(array_cache, unroll_into); - (unroll_into, jump_value, array_cache) = context.unroll_loop_iteration(); + + while let Some(context) = self.unroll_header(function, unroll_into, jump_value)? { + (unroll_into, jump_value) = context.unroll_loop_iteration(); } Ok(()) @@ -872,7 +860,7 @@ impl<'f> LoopIteration<'f> { /// It is expected the terminator instructions are set up to branch into an empty block /// for further unrolling. When the loop is finished this will need to be mutated to /// jump to the end of the loop instead. - fn unroll_loop_iteration(mut self) -> (BasicBlockId, ValueId, Option) { + fn unroll_loop_iteration(mut self) -> (BasicBlockId, ValueId) { let mut next_blocks = self.unroll_loop_block(); while let Some(block) = next_blocks.pop() { @@ -890,7 +878,7 @@ impl<'f> LoopIteration<'f> { .induction_value .expect("Expected to find the induction variable by end of loop iteration"); - (end_block, induction_value, self.inserter.into_array_cache()) + (end_block, induction_value) } /// Unroll a single block in the current iteration of the loop diff --git a/test_programs/execution_success/unrolling_regression_8333/Nargo.toml b/test_programs/execution_success/unrolling_regression_8333/Nargo.toml new file mode 100644 index 00000000000..2c9f57d0923 --- /dev/null +++ b/test_programs/execution_success/unrolling_regression_8333/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "unrolling_regression_8333" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/unrolling_regression_8333/src/main.nr b/test_programs/execution_success/unrolling_regression_8333/src/main.nr new file mode 100644 index 00000000000..9745ebfad03 --- /dev/null +++ b/test_programs/execution_success/unrolling_regression_8333/src/main.nr @@ -0,0 +1,9 @@ +// Regression for issue #8333 (https://github.com/noir-lang/noir/issues/8333) +fn main() -> pub [[u8; 32]; 2] { + let mut result = [[0; 32]; 2]; + let actions_data: [Field; 30] = [0; 30]; + for i in 0..1 { + result = [actions_data[i].to_be_bytes::<32>(), actions_data[i + 1].to_be_bytes::<32>()]; + } + result +} diff --git a/test_programs/execution_success/unrolling_regression_8333/stdout.txt b/test_programs/execution_success/unrolling_regression_8333/stdout.txt new file mode 100644 index 00000000000..f4f62ce2749 --- /dev/null +++ b/test_programs/execution_success/unrolling_regression_8333/stdout.txt @@ -0,0 +1 @@ +[unrolling_regression_8333] Circuit output: Vec([Vec([Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0)]), Vec([Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0)])]) \ No newline at end of file diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__expanded.snap new file mode 100644 index 00000000000..8265de500d7 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__expanded.snap @@ -0,0 +1,12 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: expanded_code +--- +fn main() -> pub [[u8; 32]; 2] { + let mut result: [[u8; 32]; 2] = [[0; 32]; 2]; + let actions_data: [Field; 30] = [0; 30]; + for i in 0..1 { + result = [actions_data[i].to_be_bytes::<32>(), actions_data[i + 1].to_be_bytes::<32>()]; + } + result +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..5479355caf4 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap @@ -0,0 +1,105 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "array", + "length": 32, + "type": { + "kind": "integer", + "sign": "unsigned", + "width": 8 + } + } + }, + "visibility": "public" + }, + "error_types": {} + }, + "bytecode": [ + "func 0", + "current witness index : _63", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63]", + "EXPR [ (1, _0) 0 ]", + "EXPR [ (1, _1) 0 ]", + "EXPR [ (1, _2) 0 ]", + "EXPR [ (1, _3) 0 ]", + "EXPR [ (1, _4) 0 ]", + "EXPR [ (1, _5) 0 ]", + "EXPR [ (1, _6) 0 ]", + "EXPR [ (1, _7) 0 ]", + "EXPR [ (1, _8) 0 ]", + "EXPR [ (1, _9) 0 ]", + "EXPR [ (1, _10) 0 ]", + "EXPR [ (1, _11) 0 ]", + "EXPR [ (1, _12) 0 ]", + "EXPR [ (1, _13) 0 ]", + "EXPR [ (1, _14) 0 ]", + "EXPR [ (1, _15) 0 ]", + "EXPR [ (1, _16) 0 ]", + "EXPR [ (1, _17) 0 ]", + "EXPR [ (1, _18) 0 ]", + "EXPR [ (1, _19) 0 ]", + "EXPR [ (1, _20) 0 ]", + "EXPR [ (1, _21) 0 ]", + "EXPR [ (1, _22) 0 ]", + "EXPR [ (1, _23) 0 ]", + "EXPR [ (1, _24) 0 ]", + "EXPR [ (1, _25) 0 ]", + "EXPR [ (1, _26) 0 ]", + "EXPR [ (1, _27) 0 ]", + "EXPR [ (1, _28) 0 ]", + "EXPR [ (1, _29) 0 ]", + "EXPR [ (1, _30) 0 ]", + "EXPR [ (1, _31) 0 ]", + "EXPR [ (1, _32) 0 ]", + "EXPR [ (1, _33) 0 ]", + "EXPR [ (1, _34) 0 ]", + "EXPR [ (1, _35) 0 ]", + "EXPR [ (1, _36) 0 ]", + "EXPR [ (1, _37) 0 ]", + "EXPR [ (1, _38) 0 ]", + "EXPR [ (1, _39) 0 ]", + "EXPR [ (1, _40) 0 ]", + "EXPR [ (1, _41) 0 ]", + "EXPR [ (1, _42) 0 ]", + "EXPR [ (1, _43) 0 ]", + "EXPR [ (1, _44) 0 ]", + "EXPR [ (1, _45) 0 ]", + "EXPR [ (1, _46) 0 ]", + "EXPR [ (1, _47) 0 ]", + "EXPR [ (1, _48) 0 ]", + "EXPR [ (1, _49) 0 ]", + "EXPR [ (1, _50) 0 ]", + "EXPR [ (1, _51) 0 ]", + "EXPR [ (1, _52) 0 ]", + "EXPR [ (1, _53) 0 ]", + "EXPR [ (1, _54) 0 ]", + "EXPR [ (1, _55) 0 ]", + "EXPR [ (1, _56) 0 ]", + "EXPR [ (1, _57) 0 ]", + "EXPR [ (1, _58) 0 ]", + "EXPR [ (1, _59) 0 ]", + "EXPR [ (1, _60) 0 ]", + "EXPR [ (1, _61) 0 ]", + "EXPR [ (1, _62) 0 ]", + "EXPR [ (1, _63) 0 ]" + ], + "debug_symbols": "dY/RCoMwDEX/Jc99UJwv/soYEmuUQmhLbIUh/vui6CYDn9Kb03NpF+ipy2Pr/BAmaJ4LdOKY3dhysJhc8LpdVgNnbJMQ6QouXK2IQj5B4zOzgRk575emiH6fCUVpYYB8r1MLB8e0nVbzs4t7taweh1xW9Vev1X9pQuvk/8UzisOO6YhD9vZC0zue5PxxlGCpz0Jb0860+wM=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_0.snap new file mode 100644 index 00000000000..5479355caf4 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_0.snap @@ -0,0 +1,105 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "array", + "length": 32, + "type": { + "kind": "integer", + "sign": "unsigned", + "width": 8 + } + } + }, + "visibility": "public" + }, + "error_types": {} + }, + "bytecode": [ + "func 0", + "current witness index : _63", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63]", + "EXPR [ (1, _0) 0 ]", + "EXPR [ (1, _1) 0 ]", + "EXPR [ (1, _2) 0 ]", + "EXPR [ (1, _3) 0 ]", + "EXPR [ (1, _4) 0 ]", + "EXPR [ (1, _5) 0 ]", + "EXPR [ (1, _6) 0 ]", + "EXPR [ (1, _7) 0 ]", + "EXPR [ (1, _8) 0 ]", + "EXPR [ (1, _9) 0 ]", + "EXPR [ (1, _10) 0 ]", + "EXPR [ (1, _11) 0 ]", + "EXPR [ (1, _12) 0 ]", + "EXPR [ (1, _13) 0 ]", + "EXPR [ (1, _14) 0 ]", + "EXPR [ (1, _15) 0 ]", + "EXPR [ (1, _16) 0 ]", + "EXPR [ (1, _17) 0 ]", + "EXPR [ (1, _18) 0 ]", + "EXPR [ (1, _19) 0 ]", + "EXPR [ (1, _20) 0 ]", + "EXPR [ (1, _21) 0 ]", + "EXPR [ (1, _22) 0 ]", + "EXPR [ (1, _23) 0 ]", + "EXPR [ (1, _24) 0 ]", + "EXPR [ (1, _25) 0 ]", + "EXPR [ (1, _26) 0 ]", + "EXPR [ (1, _27) 0 ]", + "EXPR [ (1, _28) 0 ]", + "EXPR [ (1, _29) 0 ]", + "EXPR [ (1, _30) 0 ]", + "EXPR [ (1, _31) 0 ]", + "EXPR [ (1, _32) 0 ]", + "EXPR [ (1, _33) 0 ]", + "EXPR [ (1, _34) 0 ]", + "EXPR [ (1, _35) 0 ]", + "EXPR [ (1, _36) 0 ]", + "EXPR [ (1, _37) 0 ]", + "EXPR [ (1, _38) 0 ]", + "EXPR [ (1, _39) 0 ]", + "EXPR [ (1, _40) 0 ]", + "EXPR [ (1, _41) 0 ]", + "EXPR [ (1, _42) 0 ]", + "EXPR [ (1, _43) 0 ]", + "EXPR [ (1, _44) 0 ]", + "EXPR [ (1, _45) 0 ]", + "EXPR [ (1, _46) 0 ]", + "EXPR [ (1, _47) 0 ]", + "EXPR [ (1, _48) 0 ]", + "EXPR [ (1, _49) 0 ]", + "EXPR [ (1, _50) 0 ]", + "EXPR [ (1, _51) 0 ]", + "EXPR [ (1, _52) 0 ]", + "EXPR [ (1, _53) 0 ]", + "EXPR [ (1, _54) 0 ]", + "EXPR [ (1, _55) 0 ]", + "EXPR [ (1, _56) 0 ]", + "EXPR [ (1, _57) 0 ]", + "EXPR [ (1, _58) 0 ]", + "EXPR [ (1, _59) 0 ]", + "EXPR [ (1, _60) 0 ]", + "EXPR [ (1, _61) 0 ]", + "EXPR [ (1, _62) 0 ]", + "EXPR [ (1, _63) 0 ]" + ], + "debug_symbols": "dY/RCoMwDEX/Jc99UJwv/soYEmuUQmhLbIUh/vui6CYDn9Kb03NpF+ipy2Pr/BAmaJ4LdOKY3dhysJhc8LpdVgNnbJMQ6QouXK2IQj5B4zOzgRk575emiH6fCUVpYYB8r1MLB8e0nVbzs4t7taweh1xW9Vev1X9pQuvk/8UzisOO6YhD9vZC0zue5PxxlGCpz0Jb0860+wM=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..5479355caf4 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_false_inliner_9223372036854775807.snap @@ -0,0 +1,105 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "array", + "length": 32, + "type": { + "kind": "integer", + "sign": "unsigned", + "width": 8 + } + } + }, + "visibility": "public" + }, + "error_types": {} + }, + "bytecode": [ + "func 0", + "current witness index : _63", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63]", + "EXPR [ (1, _0) 0 ]", + "EXPR [ (1, _1) 0 ]", + "EXPR [ (1, _2) 0 ]", + "EXPR [ (1, _3) 0 ]", + "EXPR [ (1, _4) 0 ]", + "EXPR [ (1, _5) 0 ]", + "EXPR [ (1, _6) 0 ]", + "EXPR [ (1, _7) 0 ]", + "EXPR [ (1, _8) 0 ]", + "EXPR [ (1, _9) 0 ]", + "EXPR [ (1, _10) 0 ]", + "EXPR [ (1, _11) 0 ]", + "EXPR [ (1, _12) 0 ]", + "EXPR [ (1, _13) 0 ]", + "EXPR [ (1, _14) 0 ]", + "EXPR [ (1, _15) 0 ]", + "EXPR [ (1, _16) 0 ]", + "EXPR [ (1, _17) 0 ]", + "EXPR [ (1, _18) 0 ]", + "EXPR [ (1, _19) 0 ]", + "EXPR [ (1, _20) 0 ]", + "EXPR [ (1, _21) 0 ]", + "EXPR [ (1, _22) 0 ]", + "EXPR [ (1, _23) 0 ]", + "EXPR [ (1, _24) 0 ]", + "EXPR [ (1, _25) 0 ]", + "EXPR [ (1, _26) 0 ]", + "EXPR [ (1, _27) 0 ]", + "EXPR [ (1, _28) 0 ]", + "EXPR [ (1, _29) 0 ]", + "EXPR [ (1, _30) 0 ]", + "EXPR [ (1, _31) 0 ]", + "EXPR [ (1, _32) 0 ]", + "EXPR [ (1, _33) 0 ]", + "EXPR [ (1, _34) 0 ]", + "EXPR [ (1, _35) 0 ]", + "EXPR [ (1, _36) 0 ]", + "EXPR [ (1, _37) 0 ]", + "EXPR [ (1, _38) 0 ]", + "EXPR [ (1, _39) 0 ]", + "EXPR [ (1, _40) 0 ]", + "EXPR [ (1, _41) 0 ]", + "EXPR [ (1, _42) 0 ]", + "EXPR [ (1, _43) 0 ]", + "EXPR [ (1, _44) 0 ]", + "EXPR [ (1, _45) 0 ]", + "EXPR [ (1, _46) 0 ]", + "EXPR [ (1, _47) 0 ]", + "EXPR [ (1, _48) 0 ]", + "EXPR [ (1, _49) 0 ]", + "EXPR [ (1, _50) 0 ]", + "EXPR [ (1, _51) 0 ]", + "EXPR [ (1, _52) 0 ]", + "EXPR [ (1, _53) 0 ]", + "EXPR [ (1, _54) 0 ]", + "EXPR [ (1, _55) 0 ]", + "EXPR [ (1, _56) 0 ]", + "EXPR [ (1, _57) 0 ]", + "EXPR [ (1, _58) 0 ]", + "EXPR [ (1, _59) 0 ]", + "EXPR [ (1, _60) 0 ]", + "EXPR [ (1, _61) 0 ]", + "EXPR [ (1, _62) 0 ]", + "EXPR [ (1, _63) 0 ]" + ], + "debug_symbols": "dY/RCoMwDEX/Jc99UJwv/soYEmuUQmhLbIUh/vui6CYDn9Kb03NpF+ipy2Pr/BAmaJ4LdOKY3dhysJhc8LpdVgNnbJMQ6QouXK2IQj5B4zOzgRk575emiH6fCUVpYYB8r1MLB8e0nVbzs4t7taweh1xW9Vev1X9pQuvk/8UzisOO6YhD9vZC0zue5PxxlGCpz0Jb0860+wM=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..44c6ffe67ca --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap @@ -0,0 +1,60 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "array", + "length": 32, + "type": { + "kind": "integer", + "sign": "unsigned", + "width": 8 + } + } + }, + "visibility": "public" + }, + "error_types": { + "12049594436772143978": { + "error_kind": "string", + "string": "array ref-count underflow detected" + }, + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _63", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1), Witness(2), Witness(3), Witness(4), Witness(5), Witness(6), Witness(7), Witness(8), Witness(9), Witness(10), Witness(11), Witness(12), Witness(13), Witness(14), Witness(15), Witness(16), Witness(17), Witness(18), Witness(19), Witness(20), Witness(21), Witness(22), Witness(23), Witness(24), Witness(25), Witness(26), Witness(27), Witness(28), Witness(29), Witness(30), Witness(31), Witness(32), Witness(33), Witness(34), Witness(35), Witness(36), Witness(37), Witness(38), Witness(39), Witness(40), Witness(41), Witness(42), Witness(43), Witness(44), Witness(45), Witness(46), Witness(47), Witness(48), Witness(49), Witness(50), Witness(51), Witness(52), Witness(53), Witness(54), Witness(55), Witness(56), Witness(57), Witness(58), Witness(59), Witness(60), Witness(61), Witness(62), Witness(63)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32900 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 35 }, Call { location: 36 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(6), bit_size: Integer(U32), value: 0 }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(5) }, Load { destination: Relative(7), source_pointer: Relative(8) }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(3), rhs: Relative(6) }, Const { destination: Relative(10), bit_size: Integer(U32), value: 32 }, Mov { destination: Direct(32771), source: Relative(8) }, Mov { destination: Direct(32772), source: Relative(9) }, Mov { destination: Direct(32773), source: Relative(10) }, Call { location: 70 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 1 }, Const { destination: Relative(6), bit_size: Integer(U32), value: 32 }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(5) }, Load { destination: Relative(7), source_pointer: Relative(8) }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(3), rhs: Relative(6) }, Const { destination: Relative(10), bit_size: Integer(U32), value: 32 }, Mov { destination: Direct(32771), source: Relative(8) }, Mov { destination: Direct(32772), source: Relative(9) }, Mov { destination: Direct(32773), source: Relative(10) }, Call { location: 70 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 64 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 81 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 0 }, Mov { destination: Relative(2), source: Direct(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 33 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(3) }, IndirectConst { destination_pointer: Relative(2), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(3), op: Add, bit_size: U32, lhs: Relative(2), rhs: Direct(2) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 32 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(4), rhs: Relative(3) }, Mov { destination: Relative(5), source: Relative(3) }, BinaryIntOp { destination: Relative(6), op: LessThan, bit_size: U32, lhs: Relative(5), rhs: Relative(4) }, Not { destination: Relative(6), source: Relative(6), bit_size: U1 }, JumpIf { condition: Relative(6), location: 52 }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Jump { location: 46 }, Mov { destination: Relative(1), source: Direct(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(3) }, IndirectConst { destination_pointer: Relative(1), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(3), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Mov { destination: Relative(4), source: Relative(3) }, Store { destination_pointer: Relative(4), source: Relative(2) }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Store { destination_pointer: Relative(4), source: Relative(2) }, Load { destination: Relative(2), source_pointer: Relative(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 0 }, BinaryIntOp { destination: Relative(4), op: Equals, bit_size: U32, lhs: Relative(3), rhs: Relative(2) }, Not { destination: Relative(4), source: Relative(4), bit_size: U1 }, JumpIf { condition: Relative(4), location: 67 }, Call { location: 87 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(2), rhs: Direct(2) }, Store { destination_pointer: Relative(1), source: Relative(2) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 80 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 73 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 86 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 12049594436772143978 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "jZLLjoQgEEX/hTULUQsfv9IxBhU7JAQNrZNMjP8+4NUZezFJbzwW5T2Rgo0NulufrXHj9GL1Y2OdN9aaZ2unXi1mcmF1Y0l8ZAWrBWdZCVQH8gQQQApkQA4QIAFYclhyWAgWgoVgIVgIFoKFYCFYCBaCRcIigyUNSIEMyAECJFAAwZLuO2fXntvFax23fBtCGM2svHYLq91qLWdfyq7HR69ZuYOL8qGbcKbdEBiEo7E6vu38L538HxVZfoZFRr9x+jifSnnm06p4yzehUr3xb8e6R5M3qrP6LMfV9bfu8j1fnetazH7q9bB6HU23uxEGVCS8TBrORFh5lIKXMhYiFgUvq2aPv/ED", + "file_map": { + "50": { + "source": "// Regression for issue #8333 (https://github.com/noir-lang/noir/issues/8333)\nfn main() -> pub [[u8; 32]; 2] {\n let mut result = [[0; 32]; 2];\n let actions_data: [Field; 30] = [0; 30];\n for i in 0..1 {\n result = [actions_data[i].to_be_bytes::<32>(), actions_data[i + 1].to_be_bytes::<32>()];\n }\n result\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_0.snap new file mode 100644 index 00000000000..44c6ffe67ca --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_0.snap @@ -0,0 +1,60 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "array", + "length": 32, + "type": { + "kind": "integer", + "sign": "unsigned", + "width": 8 + } + } + }, + "visibility": "public" + }, + "error_types": { + "12049594436772143978": { + "error_kind": "string", + "string": "array ref-count underflow detected" + }, + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _63", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1), Witness(2), Witness(3), Witness(4), Witness(5), Witness(6), Witness(7), Witness(8), Witness(9), Witness(10), Witness(11), Witness(12), Witness(13), Witness(14), Witness(15), Witness(16), Witness(17), Witness(18), Witness(19), Witness(20), Witness(21), Witness(22), Witness(23), Witness(24), Witness(25), Witness(26), Witness(27), Witness(28), Witness(29), Witness(30), Witness(31), Witness(32), Witness(33), Witness(34), Witness(35), Witness(36), Witness(37), Witness(38), Witness(39), Witness(40), Witness(41), Witness(42), Witness(43), Witness(44), Witness(45), Witness(46), Witness(47), Witness(48), Witness(49), Witness(50), Witness(51), Witness(52), Witness(53), Witness(54), Witness(55), Witness(56), Witness(57), Witness(58), Witness(59), Witness(60), Witness(61), Witness(62), Witness(63)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32900 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 35 }, Call { location: 36 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(6), bit_size: Integer(U32), value: 0 }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(5) }, Load { destination: Relative(7), source_pointer: Relative(8) }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(3), rhs: Relative(6) }, Const { destination: Relative(10), bit_size: Integer(U32), value: 32 }, Mov { destination: Direct(32771), source: Relative(8) }, Mov { destination: Direct(32772), source: Relative(9) }, Mov { destination: Direct(32773), source: Relative(10) }, Call { location: 70 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 1 }, Const { destination: Relative(6), bit_size: Integer(U32), value: 32 }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(5) }, Load { destination: Relative(7), source_pointer: Relative(8) }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(3), rhs: Relative(6) }, Const { destination: Relative(10), bit_size: Integer(U32), value: 32 }, Mov { destination: Direct(32771), source: Relative(8) }, Mov { destination: Direct(32772), source: Relative(9) }, Mov { destination: Direct(32773), source: Relative(10) }, Call { location: 70 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 64 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 81 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 0 }, Mov { destination: Relative(2), source: Direct(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 33 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(3) }, IndirectConst { destination_pointer: Relative(2), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(3), op: Add, bit_size: U32, lhs: Relative(2), rhs: Direct(2) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 32 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(4), rhs: Relative(3) }, Mov { destination: Relative(5), source: Relative(3) }, BinaryIntOp { destination: Relative(6), op: LessThan, bit_size: U32, lhs: Relative(5), rhs: Relative(4) }, Not { destination: Relative(6), source: Relative(6), bit_size: U1 }, JumpIf { condition: Relative(6), location: 52 }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Jump { location: 46 }, Mov { destination: Relative(1), source: Direct(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(3) }, IndirectConst { destination_pointer: Relative(1), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(3), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Mov { destination: Relative(4), source: Relative(3) }, Store { destination_pointer: Relative(4), source: Relative(2) }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Store { destination_pointer: Relative(4), source: Relative(2) }, Load { destination: Relative(2), source_pointer: Relative(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 0 }, BinaryIntOp { destination: Relative(4), op: Equals, bit_size: U32, lhs: Relative(3), rhs: Relative(2) }, Not { destination: Relative(4), source: Relative(4), bit_size: U1 }, JumpIf { condition: Relative(4), location: 67 }, Call { location: 87 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(2), rhs: Direct(2) }, Store { destination_pointer: Relative(1), source: Relative(2) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 80 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 73 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 86 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 12049594436772143978 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "jZLLjoQgEEX/hTULUQsfv9IxBhU7JAQNrZNMjP8+4NUZezFJbzwW5T2Rgo0NulufrXHj9GL1Y2OdN9aaZ2unXi1mcmF1Y0l8ZAWrBWdZCVQH8gQQQApkQA4QIAFYclhyWAgWgoVgIVgIFoKFYCFYCBaCRcIigyUNSIEMyAECJFAAwZLuO2fXntvFax23fBtCGM2svHYLq91qLWdfyq7HR69ZuYOL8qGbcKbdEBiEo7E6vu38L538HxVZfoZFRr9x+jifSnnm06p4yzehUr3xb8e6R5M3qrP6LMfV9bfu8j1fnetazH7q9bB6HU23uxEGVCS8TBrORFh5lIKXMhYiFgUvq2aPv/ED", + "file_map": { + "50": { + "source": "// Regression for issue #8333 (https://github.com/noir-lang/noir/issues/8333)\nfn main() -> pub [[u8; 32]; 2] {\n let mut result = [[0; 32]; 2];\n let actions_data: [Field; 30] = [0; 30];\n for i in 0..1 {\n result = [actions_data[i].to_be_bytes::<32>(), actions_data[i + 1].to_be_bytes::<32>()];\n }\n result\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..44c6ffe67ca --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__force_brillig_true_inliner_9223372036854775807.snap @@ -0,0 +1,60 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "array", + "length": 2, + "type": { + "kind": "array", + "length": 32, + "type": { + "kind": "integer", + "sign": "unsigned", + "width": 8 + } + } + }, + "visibility": "public" + }, + "error_types": { + "12049594436772143978": { + "error_kind": "string", + "string": "array ref-count underflow detected" + }, + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _63", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63]", + "BRILLIG CALL func 0: inputs: [], outputs: [Array([Witness(0), Witness(1), Witness(2), Witness(3), Witness(4), Witness(5), Witness(6), Witness(7), Witness(8), Witness(9), Witness(10), Witness(11), Witness(12), Witness(13), Witness(14), Witness(15), Witness(16), Witness(17), Witness(18), Witness(19), Witness(20), Witness(21), Witness(22), Witness(23), Witness(24), Witness(25), Witness(26), Witness(27), Witness(28), Witness(29), Witness(30), Witness(31), Witness(32), Witness(33), Witness(34), Witness(35), Witness(36), Witness(37), Witness(38), Witness(39), Witness(40), Witness(41), Witness(42), Witness(43), Witness(44), Witness(45), Witness(46), Witness(47), Witness(48), Witness(49), Witness(50), Witness(51), Witness(52), Witness(53), Witness(54), Witness(55), Witness(56), Witness(57), Witness(58), Witness(59), Witness(60), Witness(61), Witness(62), Witness(63)])]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32900 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 35 }, Call { location: 36 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(6), bit_size: Integer(U32), value: 0 }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(5) }, Load { destination: Relative(7), source_pointer: Relative(8) }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(3), rhs: Relative(6) }, Const { destination: Relative(10), bit_size: Integer(U32), value: 32 }, Mov { destination: Direct(32771), source: Relative(8) }, Mov { destination: Direct(32772), source: Relative(9) }, Mov { destination: Direct(32773), source: Relative(10) }, Call { location: 70 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 1 }, Const { destination: Relative(6), bit_size: Integer(U32), value: 32 }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(2), rhs: Relative(5) }, Load { destination: Relative(7), source_pointer: Relative(8) }, BinaryIntOp { destination: Relative(8), op: Add, bit_size: U32, lhs: Relative(7), rhs: Direct(2) }, BinaryIntOp { destination: Relative(9), op: Add, bit_size: U32, lhs: Relative(3), rhs: Relative(6) }, Const { destination: Relative(10), bit_size: Integer(U32), value: 32 }, Mov { destination: Direct(32771), source: Relative(8) }, Mov { destination: Direct(32772), source: Relative(9) }, Mov { destination: Direct(32773), source: Relative(10) }, Call { location: 70 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 64 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 81 }, Const { destination: Relative(1), bit_size: Integer(U8), value: 0 }, Mov { destination: Relative(2), source: Direct(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 33 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(3) }, IndirectConst { destination_pointer: Relative(2), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(3), op: Add, bit_size: U32, lhs: Relative(2), rhs: Direct(2) }, Const { destination: Relative(4), bit_size: Integer(U32), value: 32 }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(4), rhs: Relative(3) }, Mov { destination: Relative(5), source: Relative(3) }, BinaryIntOp { destination: Relative(6), op: LessThan, bit_size: U32, lhs: Relative(5), rhs: Relative(4) }, Not { destination: Relative(6), source: Relative(6), bit_size: U1 }, JumpIf { condition: Relative(6), location: 52 }, Store { destination_pointer: Relative(5), source: Relative(1) }, BinaryIntOp { destination: Relative(5), op: Add, bit_size: U32, lhs: Relative(5), rhs: Direct(2) }, Jump { location: 46 }, Mov { destination: Relative(1), source: Direct(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 3 }, BinaryIntOp { destination: Direct(1), op: Add, bit_size: U32, lhs: Direct(1), rhs: Relative(3) }, IndirectConst { destination_pointer: Relative(1), bit_size: Integer(U32), value: 1 }, BinaryIntOp { destination: Relative(3), op: Add, bit_size: U32, lhs: Relative(1), rhs: Direct(2) }, Mov { destination: Relative(4), source: Relative(3) }, Store { destination_pointer: Relative(4), source: Relative(2) }, BinaryIntOp { destination: Relative(4), op: Add, bit_size: U32, lhs: Relative(4), rhs: Direct(2) }, Store { destination_pointer: Relative(4), source: Relative(2) }, Load { destination: Relative(2), source_pointer: Relative(1) }, Const { destination: Relative(3), bit_size: Integer(U32), value: 0 }, BinaryIntOp { destination: Relative(4), op: Equals, bit_size: U32, lhs: Relative(3), rhs: Relative(2) }, Not { destination: Relative(4), source: Relative(4), bit_size: U1 }, JumpIf { condition: Relative(4), location: 67 }, Call { location: 87 }, BinaryIntOp { destination: Relative(2), op: Add, bit_size: U32, lhs: Relative(2), rhs: Direct(2) }, Store { destination_pointer: Relative(1), source: Relative(2) }, Return, BinaryIntOp { destination: Direct(32775), op: Add, bit_size: U32, lhs: Direct(32771), rhs: Direct(32773) }, Mov { destination: Direct(32776), source: Direct(32771) }, Mov { destination: Direct(32777), source: Direct(32772) }, BinaryIntOp { destination: Direct(32778), op: Equals, bit_size: U32, lhs: Direct(32776), rhs: Direct(32775) }, JumpIf { condition: Direct(32778), location: 80 }, Load { destination: Direct(32774), source_pointer: Direct(32776) }, Store { destination_pointer: Direct(32777), source: Direct(32774) }, BinaryIntOp { destination: Direct(32776), op: Add, bit_size: U32, lhs: Direct(32776), rhs: Direct(2) }, BinaryIntOp { destination: Direct(32777), op: Add, bit_size: U32, lhs: Direct(32777), rhs: Direct(2) }, Jump { location: 73 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 86 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 12049594436772143978 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "jZLLjoQgEEX/hTULUQsfv9IxBhU7JAQNrZNMjP8+4NUZezFJbzwW5T2Rgo0NulufrXHj9GL1Y2OdN9aaZ2unXi1mcmF1Y0l8ZAWrBWdZCVQH8gQQQApkQA4QIAFYclhyWAgWgoVgIVgIFoKFYCFYCBaCRcIigyUNSIEMyAECJFAAwZLuO2fXntvFax23fBtCGM2svHYLq91qLWdfyq7HR69ZuYOL8qGbcKbdEBiEo7E6vu38L538HxVZfoZFRr9x+jifSnnm06p4yzehUr3xb8e6R5M3qrP6LMfV9bfu8j1fnetazH7q9bB6HU23uxEGVCS8TBrORFh5lIKXMhYiFgUvq2aPv/ED", + "file_map": { + "50": { + "source": "// Regression for issue #8333 (https://github.com/noir-lang/noir/issues/8333)\nfn main() -> pub [[u8; 32]; 2] {\n let mut result = [[0; 32]; 2];\n let actions_data: [Field; 30] = [0; 30];\n for i in 0..1 {\n result = [actions_data[i].to_be_bytes::<32>(), actions_data[i + 1].to_be_bytes::<32>()];\n }\n result\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__stdout.snap b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__stdout.snap new file mode 100644 index 00000000000..3143d3755e1 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/unrolling_regression_8333/execute__tests__stdout.snap @@ -0,0 +1,5 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: stdout +--- +[unrolling_regression_8333] Circuit output: Vec([Vec([Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0)]), Vec([Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0), Field(0)])]) From 7f4ecb4a7ce30bfaf23e5da80ffce73dac05378f Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 21 May 2025 19:04:37 +0000 Subject: [PATCH 2/3] remove old clone --- compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs index 6cd3d1a3630..479c065e51e 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs @@ -113,7 +113,7 @@ impl<'f> FunctionInserter<'f> { .then(|| vecmap(&results, |result| self.function.dfg.type_of_value(*result))); let new_results = self.function.dfg.insert_instruction_and_results( - instruction.clone(), + instruction, block, ctrl_typevars, call_stack, From 4d3c5b7b54e74b8a9a7ad1a2552d2fec9665e9d6 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Fri, 23 May 2025 18:51:01 +0000 Subject: [PATCH 3/3] bump rollup-base-public mem limit 1500 -> 1650 --- .github/benchmark_projects.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/benchmark_projects.yml b/.github/benchmark_projects.yml index 0afd75a2dd2..bc54a4fa993 100644 --- a/.github/benchmark_projects.yml +++ b/.github/benchmark_projects.yml @@ -47,7 +47,7 @@ projects: timeout: 15 compilation-timeout: 20 execution-timeout: 0.75 - compilation-memory-limit: 1500 + compilation-memory-limit: 1650 execution-memory-limit: 550 rollup-block-root-empty: repo: AztecProtocol/aztec-packages