From 16255b4d3b705b6e3213dad7417717fae07c4a19 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Sun, 29 Dec 2024 23:56:32 +0530 Subject: [PATCH] fix: dont do 64 byte simd if not available on cpu --- fuel-vm/src/interpreter/memory.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fuel-vm/src/interpreter/memory.rs b/fuel-vm/src/interpreter/memory.rs index fce76b1c0..a47a6633c 100644 --- a/fuel-vm/src/interpreter/memory.rs +++ b/fuel-vm/src/interpreter/memory.rs @@ -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, @@ -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::::from_slice(&a[i..]); let chunk_b = Simd::::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::::from_slice(&a[i..]); let chunk_b = Simd::::from_slice(&b[i..]);