Skip to content

Commit d7013a3

Browse files
committed
Make ARMv7+NEON run alignment-sensitive SIMD code.
1 parent 767bc2a commit d7013a3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/ascii.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// different approaches based on benchmarking on Raspberry Pi 3.
2323

2424
#[cfg(all(feature = "simd-accel",
25-
any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"))))]
25+
any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))]
2626
use simd_funcs::*;
2727

2828
// `as` truncates, so works on 32-bit, too.
@@ -604,7 +604,7 @@ cfg_if! {
604604
ascii_simd_unalign!(basic_latin_to_ascii, u16, u8, basic_latin_to_ascii_stride_neither_aligned);
605605
latin1_simd_unalign!(unpack_latin1, u8, u16, unpack_stride_neither_aligned);
606606
latin1_simd_unalign!(pack_latin1, u16, u8, pack_stride_neither_aligned);
607-
} else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
607+
} else if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2"), all(target_endian = "little", target_feature = "neon")))] {
608608
// SIMD with different instructions for aligned and unaligned loads and stores.
609609
//
610610
// Newer microarchitectures are not supposed to have a performance difference between
@@ -881,7 +881,7 @@ cfg_if! {
881881
}
882882
None
883883
}
884-
} else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
884+
} else if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2"), all(target_endian = "little", target_feature = "neon")))] {
885885
#[inline(always)]
886886
pub fn validate_ascii(slice: &[u8]) -> Option<(u8, usize)> {
887887
let src = slice.as_ptr();

src/mem.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ macro_rules! by_unit_check_simd {
200200
}
201201

202202
cfg_if!{
203-
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"))))] {
203+
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
204204
use simd_funcs::*;
205205
use stdsimd::simd::u8x16;
206206
use stdsimd::simd::u16x8;
@@ -331,7 +331,7 @@ fn utf16_valid_up_to_alu(buffer: &[u16]) -> (usize, bool) {
331331
}
332332

333333
cfg_if!{
334-
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"))))] {
334+
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
335335
#[inline(always)]
336336
fn is_str_latin1_impl(buffer: &str) -> Option<usize> {
337337
let mut offset = 0usize;
@@ -420,7 +420,7 @@ fn is_utf8_latin1_impl(buffer: &[u8]) -> Option<usize> {
420420
}
421421

422422
cfg_if!{
423-
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"))))] {
423+
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
424424
#[inline(always)]
425425
fn is_utf16_bidi_impl(buffer: &[u16]) -> bool {
426426
let mut offset = 0usize;
@@ -470,7 +470,7 @@ cfg_if!{
470470
}
471471

472472
cfg_if!{
473-
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"))))] {
473+
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
474474
#[inline(always)]
475475
fn check_utf16_for_latin1_and_bidi_impl(buffer: &[u16]) -> Latin1Bidi {
476476
let mut offset = 0usize;

0 commit comments

Comments
 (0)