Skip to content

Commit

Permalink
chore: use simd struct instead and fix inc
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Dec 29, 2024
1 parent 30248be commit b6ed50b
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions fuel-vm/src/interpreter/memory.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#![cfg(feature = "alloc")]

#[cfg(feature = "experimental")]
use core::simd::{
u8x16,
u8x32,
u8x64,
};
use core::simd::Simd;

use super::{
internal::inc_pc,
Expand Down Expand Up @@ -1048,28 +1044,33 @@ fn slice_eq(a: &[u8], b: &[u8]) -> bool {
let len = a.len();
let mut i = 0;

// Process chunks of 64 bytes
while i + 64 <= len {
let simd_a = u8x64::from_slice(&a[i..]);
let simd_b = u8x64::from_slice(&b[i..]);
if simd_a != simd_b {
let chunk_a = Simd::<u8, 64>::from_slice(&a[i..]);
let chunk_b = Simd::<u8, 64>::from_slice(&b[i..]);
if chunk_a != chunk_b {
return false;
}
i += 64;
}

// Process chunks of 32 bytes
while i + 32 <= len {
let simd_a = u8x32::from_slice(&a[i..]);
let simd_b = u8x32::from_slice(&b[i..]);
if simd_a != simd_b {
let chunk_a = Simd::<u8, 32>::from_slice(&a[i..]);
let chunk_b = Simd::<u8, 32>::from_slice(&b[i..]);
if chunk_a != chunk_b {
return false;
}
i += 32;
}

while i + 16 <= len {
let simd_a = u8x16::from_slice(&a[i..]);
let simd_b = u8x16::from_slice(&b[i..]);
if simd_a != simd_b {
let chunk_a = Simd::<u8, 16>::from_slice(&a[i..]);
let chunk_b = Simd::<u8, 16>::from_slice(&b[i..]);
if chunk_a != chunk_b {
return false;
}
i += 16;
}

while i < len {
Expand Down

0 comments on commit b6ed50b

Please sign in to comment.