From d099f72175907fc5f8346e2e06daba88bb34cf12 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Sun, 11 Aug 2024 23:04:05 -0600 Subject: [PATCH] Sse4 fix (#178) * restore a test that wasn't marked as a test. * remove the case that calls non-existing functions * add a CI to prevent this from happening again. * conditional sse4.1 testing --- .github/workflows/rust.yml | 12 ++++++++---- src/u16x16_.rs | 7 +------ tests/all_tests/t_u32x8.rs | 3 ++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 20db88f..c290b9a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,10 +21,10 @@ jobs: - { target: i686-pc-windows-msvc, toolchain: beta, os: windows-latest } - { target: i686-pc-windows-msvc, toolchain: nightly, os: windows-latest } # x86_64 - - { target: x86_64-pc-windows-msvc, toolchain: "1.61", os: windows-latest } - - { target: x86_64-pc-windows-msvc, toolchain: stable, os: windows-latest } - - { target: x86_64-pc-windows-msvc, toolchain: beta, os: windows-latest } - - { target: x86_64-pc-windows-msvc, toolchain: nightly, os: windows-latest } + - { target: x86_64-unknown-linux-gnu, toolchain: "1.61", os: ubuntu-latest } + - { target: x86_64-unknown-linux-gnu, toolchain: stable, os: ubuntu-latest } + - { target: x86_64-unknown-linux-gnu, toolchain: beta, os: ubuntu-latest } + - { target: x86_64-unknown-linux-gnu, toolchain: nightly, os: ubuntu-latest } # aarch64 - { target: aarch64-apple-darwin, toolchain: "1.61", os: macos-latest } - { target: aarch64-apple-darwin, toolchain: stable, os: macos-latest } @@ -59,6 +59,10 @@ jobs: env: CARGO_TARGET_WASM32_WASI_RUNNER: wasmtime run --wasm-features all --dir . run: cargo test --target ${{ matrix.rust.target }} --all-features + + - name: Build the crate with SSE4.1 (the "native" of CI will be above this) + if: matrix.rust.os == 'ubuntu-latest' && matrix.rust.target == 'x86_64-unknown-linux-gnu' + run: RUSTFLAGS="-Ctarget-feature=+sse4.1" cargo build --target ${{ matrix.rust.target }} - name: switch over to native cpu features run: mv .cargo-ci .cargo diff --git a/src/u16x16_.rs b/src/u16x16_.rs index 0ff6024..565dce8 100644 --- a/src/u16x16_.rs +++ b/src/u16x16_.rs @@ -231,18 +231,13 @@ impl Mul for u16x16 { } impl From for u16x16 { - /// widens and sign extends to i16x16 + /// widens and sign extends to u16x16 #[inline] #[must_use] fn from(v: u8x16) -> Self { pick! { if #[cfg(target_feature="avx2")] { u16x16 { avx2:convert_to_i16_m256i_from_u8_m128i(v.sse) } - } else if #[cfg(target_feature="sse4.1")] { - u16x16 { - a: u16x8 { sse: convert_to_i16_m128i_from_lower8_u8_m128i(v.sse) }, - b: u16x8 { sse: convert_to_i16_m128i_from_lower8_u8_m128i(unpack_high_i64_m128i(v.sse, v.sse)) } - } } else if #[cfg(target_feature="sse2")] { u16x16 { a: u16x8 { sse: shr_imm_u16_m128i::<8>( unpack_low_i8_m128i(v.sse, v.sse)) }, diff --git a/tests/all_tests/t_u32x8.rs b/tests/all_tests/t_u32x8.rs index d4038d4..da6599a 100644 --- a/tests/all_tests/t_u32x8.rs +++ b/tests/all_tests/t_u32x8.rs @@ -268,7 +268,8 @@ fn impl_u32x8_from_u16x8() { |a, _b| a as u32, ); } - + +#[test] fn test_u32x8_any() { let a = u32x8::from([0, 0, 0, u32::MAX, 0, 0, 0, 0]); assert!(a.any());