Skip to content

Commit

Permalink
Merge 3bee99a into c23463e
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Aug 28, 2024
2 parents c23463e + 3bee99a commit 3e4092a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,14 @@ impl<F: AcirField + DebugToString> BrilligContext<F> {
let index_at_end_of_array = self.allocate_register();
let end_value_register = self.allocate_register();

self.codegen_loop(iteration_count, |ctx, iterator_register| {
// Load both values
ctx.codegen_array_get(vector.pointer, iterator_register, start_value_register);
self.mov_instruction(index_at_end_of_array, vector.size);

self.codegen_loop(iteration_count, |ctx, iterator_register| {
// The index at the end of array is size - 1 - iterator
ctx.mov_instruction(index_at_end_of_array, vector.size);
ctx.codegen_usize_op_in_place(index_at_end_of_array, BrilligBinaryOp::Sub, 1);
ctx.memory_op_instruction(
index_at_end_of_array,
iterator_register.address,
index_at_end_of_array,
BrilligBinaryOp::Sub,
);

// Load both values
ctx.codegen_array_get(vector.pointer, iterator_register, start_value_register);
ctx.codegen_array_get(
vector.pointer,
SingleAddrVariable::new_usize(index_at_end_of_array),
Expand Down

0 comments on commit 3e4092a

Please sign in to comment.