From 2e42e24c929d9aea190c80fd29512ce24791841f Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 8 Jan 2025 02:57:11 -0500 Subject: [PATCH] opt: try removing get_ref --- extensions/native/compiler/src/ir/poseidon.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extensions/native/compiler/src/ir/poseidon.rs b/extensions/native/compiler/src/ir/poseidon.rs index 0947cb0819..95426ab697 100644 --- a/extensions/native/compiler/src/ir/poseidon.rs +++ b/extensions/native/compiler/src/ir/poseidon.rs @@ -130,7 +130,10 @@ impl Builder { builder.set(&state, i, C::F::ZERO); }); - let address = self.get_ref(&state, 0).ptr.address; + let address = match state { + Array::Fixed(_) => panic!("Poseidon2 hash is not allowed on fixed arrays"), + Array::Dyn(ptr, _) => ptr.address, + }; let idx: Var<_> = self.eval(C::N::ZERO); self.iter(&array).for_each(|subarray, builder| { builder.iter(&subarray).for_each(|element, builder| { @@ -151,7 +154,12 @@ impl Builder { .if_eq(idx, C::N::from_canonical_usize(HASH_RATE)) .then(|builder| { builder.poseidon2_permute_mut(&state); - let start = builder.get_ref(&state, 0).ptr.address; + let start = match state { + Array::Fixed(_) => { + panic!("Poseidon2 hash is not allowed on fixed arrays") + } + Array::Dyn(ptr, _) => ptr.address, + }; builder.assign(&address, start); builder.assign(&idx, C::N::ZERO); });