This commit is contained in:
Anton-4 2022-06-15 13:58:46 +02:00
parent 47a24ad142
commit 2f08caceee
No known key found for this signature in database
GPG Key ID: C954D6E0F9C0ABFD
2 changed files with 40 additions and 8 deletions

View File

@ -252,14 +252,26 @@ impl SmallStringInterner {
#[allow(dead_code)]
fn find_i16_slice(slice: &[i16], key: i16) -> Option<usize> {
// run with RUSTFLAGS="-C target-cpu=native" to enable
#[cfg(all(target_arch = "x86_64", target_feature = "avx", target_feature = "avx2"))]
#[cfg(all(
target_arch = "x86_64",
target_feature = "avx",
target_feature = "avx2"
))]
return find_i16_slice_x86_64(slice, key);
#[cfg(not(all(target_arch = "x86_64", target_feature = "avx", target_feature = "avx2")))]
#[cfg(not(all(
target_arch = "x86_64",
target_feature = "avx",
target_feature = "avx2"
)))]
return find_i16_slice_fallback(slice, key);
}
#[cfg(all(target_arch = "x86_64", target_feature = "avx", target_feature = "avx2"))]
#[cfg(all(
target_arch = "x86_64",
target_feature = "avx",
target_feature = "avx2"
))]
fn find_i16_slice_x86_64(slice: &[i16], key: i16) -> Option<usize> {
use std::arch::x86_64::*;
@ -333,7 +345,11 @@ mod test {
assert!(interner.find_and_update("c", "cd").is_some());
}
#[cfg(all(target_arch = "x86_64", target_feature = "avx", target_feature = "avx2"))]
#[cfg(all(
target_arch = "x86_64",
target_feature = "avx",
target_feature = "avx2"
))]
#[test]
fn find_test_1() {
use super::find_i16_slice;

View File

@ -255,7 +255,11 @@ fn fast_eat_spaces(state: &State) -> FastSpaceState {
// try to use SIMD instructions explicitly
// run with RUSTFLAGS="-C target-cpu=native" to enable
#[cfg(all(target_arch = "x86_64", target_feature = "sse2", target_feature = "sse4.2"))]
#[cfg(all(
target_arch = "x86_64",
target_feature = "sse2",
target_feature = "sse4.2"
))]
{
use std::arch::x86_64::*;
@ -288,7 +292,11 @@ fn fast_eat_spaces(state: &State) -> FastSpaceState {
}
}
#[cfg(not(all(target_arch = "x86_64", target_feature = "sse2", target_feature = "sse4.2")))]
#[cfg(not(all(
target_arch = "x86_64",
target_feature = "sse2",
target_feature = "sse4.2"
)))]
{
while index < length {
match bytes[index] {
@ -432,7 +440,11 @@ fn eat_line_comment<'a>(
let loop_start = index;
#[cfg(all(target_arch = "x86_64", target_feature = "sse2", target_feature = "sse4.2"))]
#[cfg(all(
target_arch = "x86_64",
target_feature = "sse2",
target_feature = "sse4.2"
))]
{
use std::arch::x86_64::*;
@ -520,7 +532,11 @@ fn eat_line_comment<'a>(
}
}
#[cfg(not(all(target_arch = "x86_64", target_feature = "sse2", target_feature = "sse4.2")))]
#[cfg(not(all(
target_arch = "x86_64",
target_feature = "sse2",
target_feature = "sse4.2"
)))]
while index < length {
match bytes[index] {
b'\t' => unreachable!(),