From ede8a74f1e73af264de44a73e531e270a3d65c99 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Thu, 14 Nov 2024 14:07:47 -0700 Subject: [PATCH 1/2] tests/run-make/simd-ffi: fix test crashing on x86 targets ... ... that do not have SSE2 support (e.g. i586) --- tests/run-make/simd-ffi/simd.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run-make/simd-ffi/simd.rs b/tests/run-make/simd-ffi/simd.rs index b72078faafa..4b86b808d81 100644 --- a/tests/run-make/simd-ffi/simd.rs +++ b/tests/run-make/simd-ffi/simd.rs @@ -25,7 +25,7 @@ pub struct i32x4([i32; 4]); extern "C" { // _mm_sll_epi32 - #[cfg(any(target_arch = "x86", target_arch = "x86-64"))] + #[cfg(all(any(target_arch = "x86", target_arch = "x86-64"), target_feature = "sse2"))] #[link_name = "llvm.x86.sse2.psll.d"] fn integer(a: i32x4, b: i32x4) -> i32x4; @@ -42,7 +42,7 @@ extern "C" { // we still get type checking, but not as detailed as (ab)using // LLVM. #[cfg(not(any( - target_arch = "x86", + all(target_arch = "x86", target_feature = "sse2"), target_arch = "x86-64", target_arch = "arm", target_arch = "aarch64" From 0733ed77d16a691863166561bc8b286a79fa8584 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Thu, 14 Nov 2024 14:08:39 -0700 Subject: [PATCH 2/2] tests/run-make/simd-ffi: use a generic LLVM intrinsics ... ... to do more comprehensive type checking --- tests/run-make/simd-ffi/simd.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/run-make/simd-ffi/simd.rs b/tests/run-make/simd-ffi/simd.rs index 4b86b808d81..9ea8eb8cf88 100644 --- a/tests/run-make/simd-ffi/simd.rs +++ b/tests/run-make/simd-ffi/simd.rs @@ -38,15 +38,13 @@ extern "C" { #[link_name = "llvm.aarch64.neon.maxs.v4i32"] fn integer(a: i32x4, b: i32x4) -> i32x4; - // just some substitute foreign symbol, not an LLVM intrinsic; so - // we still get type checking, but not as detailed as (ab)using - // LLVM. + // Use a generic LLVM intrinsic to do type checking on other platforms #[cfg(not(any( - all(target_arch = "x86", target_feature = "sse2"), - target_arch = "x86-64", + all(any(target_arch = "x86", target_arch = "x86-64"), target_feature = "sse2"), target_arch = "arm", target_arch = "aarch64" )))] + #[link_name = "llvm.smax.v4i32"] fn integer(a: i32x4, b: i32x4) -> i32x4; }