Skip to content

Commit

Permalink
Make ARMv7+NEON run alignment-sensitive SIMD code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsivonen committed Apr 13, 2018
1 parent 767bc2a commit d7013a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// different approaches based on benchmarking on Raspberry Pi 3.

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

// `as` truncates, so works on 32-bit, too.
Expand Down Expand Up @@ -604,7 +604,7 @@ cfg_if! {
ascii_simd_unalign!(basic_latin_to_ascii, u16, u8, basic_latin_to_ascii_stride_neither_aligned);
latin1_simd_unalign!(unpack_latin1, u8, u16, unpack_stride_neither_aligned);
latin1_simd_unalign!(pack_latin1, u16, u8, pack_stride_neither_aligned);
} else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
} else if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2"), all(target_endian = "little", target_feature = "neon")))] {
// SIMD with different instructions for aligned and unaligned loads and stores.
//
// Newer microarchitectures are not supposed to have a performance difference between
Expand Down Expand Up @@ -881,7 +881,7 @@ cfg_if! {
}
None
}
} else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
} else if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2"), all(target_endian = "little", target_feature = "neon")))] {
#[inline(always)]
pub fn validate_ascii(slice: &[u8]) -> Option<(u8, usize)> {
let src = slice.as_ptr();
Expand Down
8 changes: 4 additions & 4 deletions src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ macro_rules! by_unit_check_simd {
}

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

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

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

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

0 comments on commit d7013a3

Please sign in to comment.