Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6f55c6a
Add integration test
aakoshh Jul 28, 2025
b90730e
Keep first range check with minimum bit size
aakoshh Jul 28, 2025
75d75fe
Update insta
aakoshh Jul 28, 2025
752d323
Don't offset the implied bit size by 1
aakoshh Jul 28, 2025
eb728c5
Only keep RANGE if there might be a side effect
aakoshh Jul 29, 2025
986d31d
Update insta
aakoshh Jul 29, 2025
b908bd9
Clippy
aakoshh Jul 29, 2025
96b8335
Add unit test
aakoshh Jul 29, 2025
3183db2
Add docs
aakoshh Jul 29, 2025
9af7cba
Consider an overflow in Brillig equivalent to a constraint failure in…
aakoshh Jul 29, 2025
8670663
Double optimisation should not remove RANGE
aakoshh Jul 29, 2025
21e54ce
Update insta
aakoshh Jul 29, 2025
98f0d2a
Consider any side effect as a need to emit the range constraint
aakoshh Jul 29, 2025
25e4857
Update insta
aakoshh Jul 29, 2025
702cf78
Pass in information about Brillig functions
aakoshh Jul 29, 2025
eeeb7ec
Update insta
aakoshh Jul 29, 2025
7a179e6
Implement switch-point logic
aakoshh Jul 29, 2025
126b35b
Fix labeling
aakoshh Jul 29, 2025
68783be
Update insta
aakoshh Jul 29, 2025
5eb8b53
Clippy
aakoshh Jul 29, 2025
541135b
Merge branch 'master' into af/9335-fix-acir-redundant-range
aakoshh Jul 29, 2025
86ba805
Simplify RangeInfo
aakoshh Jul 29, 2025
111c940
Track side effects during range removal
aakoshh Jul 29, 2025
7b3498b
Rephrase docs
aakoshh Jul 29, 2025
a5b2044
Merge branch 'master' into af/9335-fix-acir-redundant-range
aakoshh Aug 11, 2025
875e518
Merge remote-tracking branch 'origin/master' into af/9335-fix-acir-re…
aakoshh Aug 11, 2025
5b96892
Move around assertions to get rid of size regression in strings test
aakoshh Aug 11, 2025
48468a5
Merge branch 'af/9335-fix-acir-redundant-range' of github.com:noir-la…
aakoshh Aug 11, 2025
46286a0
Reduce bit size by restricting index to maximum value, rather than th…
aakoshh Aug 11, 2025
710ec29
Update insta
aakoshh Aug 11, 2025
7392389
Merge remote-tracking branch 'origin/master' into af/9335-fix-acir-re…
aakoshh Aug 11, 2025
e0de94c
Merge remote-tracking branch 'origin/master' into af/9335-fix-acir-re…
aakoshh Aug 14, 2025
5a886d6
Merge remote-tracking branch 'origin/master' into af/9335-fix-acir-re…
aakoshh Aug 15, 2025
08a3544
Merge branch 'master' into af/9335-fix-acir-redundant-range
aakoshh Aug 19, 2025
9e84d62
Bump rollup-block-root-empty timeout
aakoshh Aug 19, 2025
53f0187
Merge remote-tracking branch 'origin/master' into af/9335-fix-acir-re…
aakoshh Aug 19, 2025
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 .github/benchmark_projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ projects:
cannot_execute: true
num_runs: 5
timeout: 60
compilation-timeout: 25
compilation-timeout: 30
compilation-memory-limit: 1500
rollup-block-root-single-tx:
repo: AztecProtocol/aztec-packages
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

13 changes: 9 additions & 4 deletions acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};

use acir::{
AcirField,
circuit::{AcirOpcodeLocation, AssertionPayload, Circuit, ExpressionWidth, OpcodeLocation},
circuit::{
AcirOpcodeLocation, AssertionPayload, Circuit, ExpressionWidth, OpcodeLocation,
brillig::BrilligFunctionId,
},
};

// The various passes that we can use over ACIR
Expand Down Expand Up @@ -92,13 +95,15 @@ fn transform_assert_messages<F: Clone>(
pub fn compile<F: AcirField>(
acir: Circuit<F>,
expression_width: ExpressionWidth,
brillig_side_effects: &BTreeMap<BrilligFunctionId, bool>,
) -> (Circuit<F>, AcirTransformationMap) {
let acir_opcode_positions = (0..acir.opcodes.len()).collect::<Vec<_>>();

let (acir, acir_opcode_positions) = optimize_internal(acir, acir_opcode_positions);
let (acir, acir_opcode_positions) =
optimize_internal(acir, acir_opcode_positions, brillig_side_effects);

let (mut acir, acir_opcode_positions) =
transform_internal(acir, expression_width, acir_opcode_positions);
transform_internal(acir, expression_width, acir_opcode_positions, brillig_side_effects);

let transformation_map = AcirTransformationMap::new(&acir_opcode_positions);
acir.assert_messages = transform_assert_messages(acir.assert_messages, &transformation_map);
Expand Down
15 changes: 11 additions & 4 deletions acvm-repo/acvm/src/compiler/optimizers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::collections::BTreeMap;

use acir::{
AcirField,
circuit::{Circuit, Opcode},
circuit::{Circuit, Opcode, brillig::BrilligFunctionId},
};

mod general;
Expand All @@ -18,12 +20,16 @@ use self::unused_memory::UnusedMemoryOptimizer;
use super::{AcirTransformationMap, transform_assert_messages};

/// Applies backend independent optimizations to a [`Circuit`].
pub fn optimize<F: AcirField>(acir: Circuit<F>) -> (Circuit<F>, AcirTransformationMap) {
pub fn optimize<F: AcirField>(
acir: Circuit<F>,
brillig_side_effects: &BTreeMap<BrilligFunctionId, bool>,
) -> (Circuit<F>, AcirTransformationMap) {
// Track original acir opcode positions throughout the transformation passes of the compilation
// by applying the modifications done to the circuit opcodes and also to the opcode_positions (delete and insert)
let acir_opcode_positions = (0..acir.opcodes.len()).collect();

let (mut acir, new_opcode_positions) = optimize_internal(acir, acir_opcode_positions);
let (mut acir, new_opcode_positions) =
optimize_internal(acir, acir_opcode_positions, brillig_side_effects);

let transformation_map = AcirTransformationMap::new(&new_opcode_positions);

Expand All @@ -39,6 +45,7 @@ pub fn optimize<F: AcirField>(acir: Circuit<F>) -> (Circuit<F>, AcirTransformati
pub(super) fn optimize_internal<F: AcirField>(
acir: Circuit<F>,
acir_opcode_positions: Vec<usize>,
brillig_side_effects: &BTreeMap<BrilligFunctionId, bool>,
) -> (Circuit<F>, Vec<usize>) {
if acir.opcodes.len() == 1 && matches!(acir.opcodes[0], Opcode::BrilligCall { .. }) {
info!("Program is fully unconstrained, skipping optimization pass");
Expand Down Expand Up @@ -70,7 +77,7 @@ pub(super) fn optimize_internal<F: AcirField>(
// ConstantBackpropagationOptimizer::backpropagate_constants(acir, acir_opcode_positions);

// Range optimization pass
let range_optimizer = RangeOptimizer::new(acir);
let range_optimizer = RangeOptimizer::new(acir, brillig_side_effects);
let (acir, acir_opcode_positions) =
range_optimizer.replace_redundant_ranges(acir_opcode_positions);

Expand Down
Loading
Loading