Skip to content

Commit

Permalink
Gate SSE41 and AVX2 vectorisation behind x86/64
Browse files Browse the repository at this point in the history
  • Loading branch information
Lynnesbian committed Sep 26, 2024
1 parent b9e8c92 commit b67c41f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
}
}

Expand Down
1 change: 0 additions & 1 deletion src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) });
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")))]
Expand Down

0 comments on commit b67c41f

Please sign in to comment.