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

fix: Disable loop unrolling in brillig #2590

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all 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
9 changes: 9 additions & 0 deletions crates/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ impl Ssa {
/// If any loop cannot be unrolled, it is left as-is or in a partially unrolled state.
pub(crate) fn unroll_loops(mut self) -> Result<Ssa, RuntimeError> {
for function in self.functions.values_mut() {
// Loop unrolling in brillig can lead to a code explosion currently. This can
// also be true for ACIR, but we have no alternative to unrolling in ACIR.
// Brillig also generally prefers smaller code rather than faster code.
if function.runtime() == RuntimeType::Brillig {
continue;
}

// This check is always true with the addition of the above guard, but I'm
// keeping it in case the guard on brillig functions is ever removed.
let abort_on_error = function.runtime() == RuntimeType::Acir;
find_all_loops(function).unroll_each_loop(function, abort_on_error)?;
}
Expand Down