Skip to content

Commit

Permalink
fix: dont do 64 byte simd if not available on cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Dec 29, 2024
1 parent b6ed50b commit 16255b4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fuel-vm/src/interpreter/memory.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#![cfg(feature = "alloc")]

#[cfg(feature = "experimental")]
use core::simd::Simd;
use core::simd::{
cmp::SimdPartialEq,
Simd,
};

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

// Process chunks of 64 bytes
#[cfg(target_feature = "avx512f")]
while i + 64 <= len {
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;
}
chunk_a.simd_eq(chunk_b).all_true();
i += 64;
}

// Process chunks of 32 bytes
#[cfg(target_feature = "avx2")]
while i + 32 <= len {
let chunk_a = Simd::<u8, 32>::from_slice(&a[i..]);
let chunk_b = Simd::<u8, 32>::from_slice(&b[i..]);
Expand Down

0 comments on commit 16255b4

Please sign in to comment.