Skip to content

Commit

Permalink
Only looping in transform
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Dec 4, 2024
1 parent 8cc215a commit 7c72b29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
22 changes: 6 additions & 16 deletions acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,13 @@ pub fn compile<F: AcirField>(
acir: Circuit<F>,
expression_width: ExpressionWidth,
) -> (Circuit<F>, 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)
}
5 changes: 2 additions & 3 deletions acvm-repo/acvm/src/compiler/transformers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: AcirField>(
Expand Down Expand Up @@ -59,7 +58,7 @@ pub(super) fn transform_internal<F: AcirField>(
// 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);

Expand Down

0 comments on commit 7c72b29

Please sign in to comment.