Skip to content

Commit

Permalink
Merge 85189aa into 97073b2
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm authored Feb 3, 2025
2 parents 97073b2 + 85189aa commit 3e610c4
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 47 deletions.
4 changes: 2 additions & 2 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ pub struct CompileOptions {
/// as it required fewer SSA instructions.
/// A higher value results in fewer jumps but a larger program.
/// A lower value keeps the original program if it was smaller, even if it has more jumps.
#[arg(long, hide = true, allow_hyphen_values = true)]
pub max_bytecode_increase_percent: Option<i32>,
#[arg(long, hide = true, allow_hyphen_values = true, default_value_t = 25)]
pub max_bytecode_increase_percent: i32,

/// Use pedantic ACVM solving, i.e. double-check some black-box function
/// assumptions when solving.
Expand Down
8 changes: 6 additions & 2 deletions compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct SsaEvaluatorOptions {
/// Maximum accepted percentage increase in the Brillig bytecode size after unrolling loops.
/// When `None` the size increase check is skipped altogether and any decrease in the SSA
/// instruction count is accepted.
pub max_bytecode_increase_percent: Option<i32>,
pub max_bytecode_increase_percent: i32,
}

pub(crate) struct ArtifactsAndWarnings(Artifacts, Vec<SsaReport>);
Expand Down Expand Up @@ -176,7 +176,11 @@ fn optimize_all(builder: SsaBuilder, options: &SsaEvaluatorOptions) -> Result<Ss
.run_pass(Ssa::loop_invariant_code_motion, "Loop Invariant Code Motion")
.try_run_pass(
|ssa| ssa.unroll_loops_iteratively(options.max_bytecode_increase_percent),
"Unrolling",
"Unrolling (1st)",
)?
.try_run_pass(
|ssa| ssa.unroll_loops_iteratively(options.max_bytecode_increase_percent),
"Unrolling (2nd)",
)?
.run_pass(Ssa::simplify_cfg, "Simplifying (2nd)")
.run_pass(Ssa::mem2reg, "Mem2Reg (3rd)")
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/opt/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod tests {
skip_underconstrained_check: true,
enable_brillig_constraints_check: false,
inliner_aggressiveness: 0,
max_bytecode_increase_percent: None,
max_bytecode_increase_percent: i32::MAX,
};

let builder = SsaBuilder {
Expand Down
7 changes: 6 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/loop_invariant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl Loops {

context.map_dependent_instructions();
context.inserter.map_data_bus_in_place();

// let new_values = context.loop_invariants.iter().map(|value| context.inserter.resolve(*value)).collect::<Vec<_>>();
// dbg!(new_values.clone());
// dbg!(context.defined_in_loop.clone());
// dbg!(context.loop_invariants.clone());
}
}

Expand All @@ -78,7 +83,7 @@ impl Loop {
/// jmpif v5 then: b3, else: b2
/// ```
/// In the example above, `v1` is the induction variable
fn get_induction_variable(&self, function: &Function) -> ValueId {
pub(crate) fn get_induction_variable(&self, function: &Function) -> ValueId {
function.dfg.block_parameters(self.header)[0]
}
}
Expand Down
Loading

0 comments on commit 3e610c4

Please sign in to comment.