Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Test default bytecode size increase percent of 0 #7250

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
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 = 0)]
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
Loading