Skip to content

Commit e7fe2e3

Browse files
nagisaLucasSte
andauthored
use a more optimal loop implementation (#131)
In platform-tools v1.53 inlining decisions of Iterator::next prevent LLVM from optimizing this loop into an unrolled index-based version of it. So where in 1.51 we'd see ```asm INLINE_MEMMOVE($from, $to, 32 bytes) jeq $length, 1, exit INLINE_MEMMOVE($from, $to, 32 bytes) jeq $length, 2, exit ... ``` In 1.53 we'd instead get a much more CU-heavy pointer-comparison based loop instead. ```asm lsh64 $index, 3 ldxdw r4, [r1 + 0] add64 r1, $index INLINE_MEMMOVE($from, $to, 32) ldxdw r6, [r10 - 48] jeq r1, r2, exit ; ... ``` Since we want an index-based loop here for optimal results, might as well write it that way directly instead of relying on optimizations to trigger. Co-authored-by: Lucas Ste <38472950+LucasSte@users.noreply.github.com>
1 parent 4a97dba commit e7fe2e3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pinocchio/program/src/processor/shared/initialize_multisig.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ pub fn process_initialize_multisig(
6666
return Err(TokenError::InvalidNumberOfRequiredSigners.into());
6767
}
6868

69-
for (i, signer_info) in remaining.iter().enumerate() {
70-
multisig.signers[i] = *signer_info.key();
69+
#[expect(clippy::needless_range_loop)] // CU use is better with index-based loop
70+
for i in 0..remaining.len() {
71+
multisig.signers[i] = *remaining[i].key();
7172
}
7273

7374
multisig.set_initialized(true);

0 commit comments

Comments
 (0)