From 7c72b29a2c6916e6f584af409364a69de6b7d4e9 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 4 Dec 2024 17:02:55 +0000 Subject: [PATCH] Only looping in transform --- acvm-repo/acvm/src/compiler/mod.rs | 22 +++++-------------- .../acvm/src/compiler/transformers/mod.rs | 5 ++--- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/acvm-repo/acvm/src/compiler/mod.rs b/acvm-repo/acvm/src/compiler/mod.rs index ad0f0d2df4c..89e0d1dbb4f 100644 --- a/acvm-repo/acvm/src/compiler/mod.rs +++ b/acvm-repo/acvm/src/compiler/mod.rs @@ -76,23 +76,13 @@ pub fn compile( acir: Circuit, expression_width: ExpressionWidth, ) -> (Circuit, AcirTransformationMap) { - let mut pass = 0; - let mut prev_acir = acir; - loop { - let (acir, acir_opcode_positions) = optimize_internal(prev_acir); + let (acir, acir_opcode_positions) = optimize_internal(acir); - let (mut acir, acir_opcode_positions) = - transform_internal(acir, expression_width, acir_opcode_positions); + let (mut acir, acir_opcode_positions) = + transform_internal(acir, expression_width, acir_opcode_positions); - let transformation_map = AcirTransformationMap::new(&acir_opcode_positions); + let transformation_map = AcirTransformationMap::new(&acir_opcode_positions); + acir.assert_messages = transform_assert_messages(acir.assert_messages, &transformation_map); - acir.assert_messages = transform_assert_messages(acir.assert_messages, &transformation_map); - - if pass == 2 { - return (acir, transformation_map); - } - println!("AFTER PASS {pass}: {acir}"); - pass += 1; - prev_acir = acir; - } + (acir, transformation_map) } diff --git a/acvm-repo/acvm/src/compiler/transformers/mod.rs b/acvm-repo/acvm/src/compiler/transformers/mod.rs index 6d342731a8b..60cb90e487f 100644 --- a/acvm-repo/acvm/src/compiler/transformers/mod.rs +++ b/acvm-repo/acvm/src/compiler/transformers/mod.rs @@ -20,8 +20,7 @@ use super::{ }; /// The `MergeExpressionOptimizer` needs multiple passes to stabilize the output. -/// Testing showed two passes to be enough. -const MAX_OPTIMIZER_PASSES: usize = 2; +const MAX_OPTIMIZER_PASSES: usize = 3; /// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`]. fn _transform( @@ -59,7 +58,7 @@ pub(super) fn transform_internal( // Allow multiple passes until we have stable output. let mut prev_opcodes_hash = fxhash::hash64(&acir.opcodes); - for _ in 0..1 { + for _ in 0..MAX_OPTIMIZER_PASSES { let (new_acir, new_acir_opcode_positions) = transform_internal_once(acir, expression_width, acir_opcode_positions);