Merge pull request #3228 from rtfeldman/illegal_instruction_PENTIUM_N3700

WIP don't require avx, avx2, sse, sse4.2 on all x86-64
This commit is contained in:
Richard Feldman 2022-06-20 08:32:14 -04:00 committed by GitHub
commit 033efe33e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 9 deletions

View file

@ -9,6 +9,10 @@ test-gen-wasm = "test -p roc_gen_wasm -p test_gen --no-default-features --featur
# lto=fat Spend extra effort on link-time optimization across crates
rustflags = ["-Copt-level=s", "-Clto=fat"]
[target.'cfg(not(target = "wasm32-unknown-unknown"))']
# Sets the avx, avx2, sse2 and sse4.2 target-features correctly based on your CPU.
rustflags = ["-Ctarget-cpu=native"]
[env]
# Gives us the path of the workspace root for use in cargo tests without having
# to compute it per-package.

View file

@ -146,6 +146,8 @@ build-nightly-release:
# compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run.
prep-bench-folder:
FROM +copy-dirs
# to make use of avx, avx2, sse2, sse4.2... instructions
ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld -C target-cpu=native"
ARG BENCH_SUFFIX=branch
RUN cargo criterion -V
RUN --mount=type=cache,target=$SCCACHE_DIR cd cli && cargo criterion --no-run

View file

@ -164,7 +164,9 @@ where
};
// flaky test error that only occurs sometimes inside MacOS ci run
if error_str.contains("unable to build stage1 zig object: FileNotFound") {
if error_str.contains("unable to build stage1 zig object: FileNotFound")
|| error_str.contains("unable to save cached ZIR code")
{
run_command(path, command_str, args)
} else {
panic!("{} failed: {}", command_str, error_str);

View file

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

View file

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