From b67c41fa70aee562b40af5e295ce123d0d6f2bfb Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Fri, 27 Sep 2024 09:20:11 +1000 Subject: [PATCH] Gate SSE41 and AVX2 vectorisation behind x86/64 --- src/decode.rs | 1 - src/encode.rs | 1 - src/lib.rs | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/decode.rs b/src/decode.rs index b1ded82..86c5bd8 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -120,7 +120,6 @@ pub fn hex_check_with_case(src: &[u8], check_case: CheckCase) -> bool { match crate::vectorization_support() { crate::Vectorization::Neon => unsafe { hex_check_neon_with_case(src, check_case) }, crate::Vectorization::None => hex_check_fallback_with_case(src, check_case), - _ => unreachable!(), } } diff --git a/src/encode.rs b/src/encode.rs index b888728..a5234a2 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -110,7 +110,6 @@ pub fn hex_encode_custom<'a>( match crate::vectorization_support() { crate::Vectorization::Neon => unsafe { hex_encode_neon(src, dst, upper_case) }, crate::Vectorization::None => hex_encode_custom_case_fallback(src, dst, upper_case), - _ => unreachable!(), } // Safety: We just wrote valid utf8 hex string into the dst return Ok(unsafe { mut_str(dst) }); diff --git a/src/lib.rs b/src/lib.rs index 97288c0..badfd0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,9 @@ pub use crate::decode::{hex_check_neon, hex_check_neon_with_case}; #[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub(crate) enum Vectorization { None = 0, + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] SSE41 = 1, + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] AVX2 = 2, #[cfg(target_arch = "aarch64")] Neon = 3, @@ -199,7 +201,6 @@ mod tests { Vectorization::None => assert!( !cfg!(target_feature = "neon") || !std::arch::is_aarch64_feature_detected!("neon") ), - _ => unreachable!(), } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))]