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

feat: Only check array bounds in brillig if index is unsafe #5938

Merged
merged 1 commit into from
Sep 5, 2024
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
12 changes: 10 additions & 2 deletions compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,11 @@ impl<'block> BrilligBlock<'block> {
};

let index_variable = self.convert_ssa_single_addr_value(*index, dfg);
self.validate_array_index(array_variable, index_variable);

if !dfg.is_safe_index(*index, *array) {
self.validate_array_index(array_variable, index_variable);
}

self.retrieve_variable_from_array(
array_pointer,
index_variable,
Expand All @@ -652,7 +656,11 @@ impl<'block> BrilligBlock<'block> {
result_ids[0],
dfg,
);
self.validate_array_index(source_variable, index_register);

if !dfg.is_safe_index(*index, *array) {
self.validate_array_index(source_variable, index_register);
}

self.convert_ssa_array_set(
source_variable,
destination_variable,
Expand Down
Loading