Skip to content

Commit 16255b4

Browse files
committed
fix: dont do 64 byte simd if not available on cpu
1 parent b6ed50b commit 16255b4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fuel-vm/src/interpreter/memory.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#![cfg(feature = "alloc")]
22

33
#[cfg(feature = "experimental")]
4-
use core::simd::Simd;
4+
use core::simd::{
5+
cmp::SimdPartialEq,
6+
Simd,
7+
};
58

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

10471050
// Process chunks of 64 bytes
1051+
#[cfg(target_feature = "avx512f")]
10481052
while i + 64 <= len {
10491053
let chunk_a = Simd::<u8, 64>::from_slice(&a[i..]);
10501054
let chunk_b = Simd::<u8, 64>::from_slice(&b[i..]);
1051-
if chunk_a != chunk_b {
1052-
return false;
1053-
}
1055+
chunk_a.simd_eq(chunk_b).all_true();
10541056
i += 64;
10551057
}
10561058

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

0 commit comments

Comments
 (0)