From e7a0f28a841fb7f8462fe80ecb472d71892d7f2d Mon Sep 17 00:00:00 2001 From: sirasistant Date: Mon, 16 Sep 2024 18:48:44 +0000 Subject: [PATCH] feat: optimize codegen_allocate_immediate --- .../src/brillig/brillig_ir/codegen_memory.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_memory.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_memory.rs index ea8969eddf3..0199d9537a6 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_memory.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_memory.rs @@ -9,7 +9,7 @@ use super::{ brillig_variable::{BrilligArray, BrilligVariable, BrilligVector, SingleAddrVariable}, debug_show::DebugToString, registers::RegisterAllocator, - BrilligContext, BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + BrilligContext, ReservedRegisters, BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, }; impl BrilligContext { @@ -20,9 +20,12 @@ impl BrilligContext< pointer_register: MemoryAddress, size: usize, ) { - let size_register = self.make_usize_constant_instruction(size.into()); - self.codegen_allocate_mem(pointer_register, size_register.address); - self.deallocate_single_addr(size_register); + self.load_free_memory_pointer_instruction(pointer_register); + self.codegen_usize_op_in_place( + ReservedRegisters::free_memory_pointer(), + BrilligBinaryOp::Add, + size, + ); } /// Allocates an array of size contained in size_register and stores the