Skip to content

Commit 216fac3

Browse files
committed
wasm, arm, x86-without-SSE need simd to be explicitly enabled
1 parent b5f5f62 commit 216fac3

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

tests/codegen/const-vector.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(repr_simd)]
99
#![feature(rustc_attrs)]
1010
#![feature(simd_ffi)]
11+
#![feature(arm_target_feature)]
1112
#![allow(non_camel_case_types)]
1213

1314
// Setting up structs that can be used as const vectors
@@ -28,40 +29,22 @@ pub struct Simd<T, const N: usize>([T; N]);
2829

2930
extern "unadjusted" {
3031
fn test_i8x2(a: i8x2);
31-
}
32-
33-
extern "unadjusted" {
3432
fn test_i8x2_two_args(a: i8x2, b: i8x2);
35-
}
36-
37-
extern "unadjusted" {
3833
fn test_i8x2_mixed_args(a: i8x2, c: i32, b: i8x2);
39-
}
40-
41-
extern "unadjusted" {
4234
fn test_i8x2_arr(a: i8x2);
43-
}
44-
45-
extern "unadjusted" {
4635
fn test_f32x2(a: f32x2);
47-
}
48-
49-
extern "unadjusted" {
5036
fn test_f32x2_arr(a: f32x2);
51-
}
52-
53-
extern "unadjusted" {
5437
fn test_simd(a: Simd<i32, 4>);
55-
}
56-
57-
extern "unadjusted" {
5838
fn test_simd_unaligned(a: Simd<i32, 3>);
5939
}
6040

6141
// Ensure the packed variant of the simd struct does not become a const vector
6242
// if the size is not a power of 2
6343
// CHECK: %"Simd<i32, 3>" = type { [3 x i32] }
6444

45+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
46+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
47+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
6548
pub fn do_call() {
6649
unsafe {
6750
// CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64>

tests/codegen/repr/transparent.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// For LoongArch: see codegen/loongarch-abi
1010

1111
#![crate_type = "lib"]
12-
#![feature(repr_simd, transparent_unions)]
12+
#![feature(repr_simd, transparent_unions, arm_target_feature)]
1313

1414
use std::marker::PhantomData;
1515

@@ -139,6 +139,9 @@ pub struct Vector(f32x4);
139139

140140
// CHECK: define{{.*}}<4 x float> @test_Vector(<4 x float> %_1)
141141
#[no_mangle]
142+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
143+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
144+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
142145
pub extern "C" fn test_Vector(_: Vector) -> Vector {
143146
loop {}
144147
}

tests/codegen/simd/extract-insert-dyn.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@compile-flags: -C opt-level=3 -C no-prepopulate-passes
22

3-
#![feature(core_intrinsics, repr_simd)]
3+
#![feature(core_intrinsics, repr_simd, arm_target_feature)]
44
#![no_std]
55
#![crate_type = "lib"]
66
#![allow(non_camel_case_types)]
@@ -21,55 +21,79 @@ pub struct i8x16([i8; 16]);
2121
// CHECK-LABEL: dyn_simd_extract
2222
// CHECK: extractelement <16 x i8> %x, i32 %idx
2323
#[no_mangle]
24+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
25+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
26+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
2427
unsafe extern "C" fn dyn_simd_extract(x: i8x16, idx: u32) -> i8 {
2528
simd_extract_dyn(x, idx)
2629
}
2730

2831
// CHECK-LABEL: literal_dyn_simd_extract
2932
// CHECK: extractelement <16 x i8> %x, i32 7
3033
#[no_mangle]
34+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
35+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
36+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
3137
unsafe extern "C" fn literal_dyn_simd_extract(x: i8x16) -> i8 {
3238
simd_extract_dyn(x, 7)
3339
}
3440

3541
// CHECK-LABEL: const_dyn_simd_extract
3642
// CHECK: extractelement <16 x i8> %x, i32 7
3743
#[no_mangle]
44+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
45+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
46+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
3847
unsafe extern "C" fn const_dyn_simd_extract(x: i8x16) -> i8 {
3948
simd_extract_dyn(x, const { 3 + 4 })
4049
}
4150

4251
// CHECK-LABEL: const_simd_extract
4352
// CHECK: extractelement <16 x i8> %x, i32 7
4453
#[no_mangle]
54+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
55+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
56+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
4557
unsafe extern "C" fn const_simd_extract(x: i8x16) -> i8 {
4658
simd_extract(x, const { 3 + 4 })
4759
}
4860

4961
// CHECK-LABEL: dyn_simd_insert
5062
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 %idx
5163
#[no_mangle]
64+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
65+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
66+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
5267
unsafe extern "C" fn dyn_simd_insert(x: i8x16, e: i8, idx: u32) -> i8x16 {
5368
simd_insert_dyn(x, idx, e)
5469
}
5570

5671
// CHECK-LABEL: literal_dyn_simd_insert
5772
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 7
5873
#[no_mangle]
74+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
75+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
76+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
5977
unsafe extern "C" fn literal_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 {
6078
simd_insert_dyn(x, 7, e)
6179
}
6280

6381
// CHECK-LABEL: const_dyn_simd_insert
6482
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 7
6583
#[no_mangle]
84+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
85+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
86+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
6687
unsafe extern "C" fn const_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 {
6788
simd_insert_dyn(x, const { 3 + 4 }, e)
6889
}
6990

7091
// CHECK-LABEL: const_simd_insert
7192
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 7
7293
#[no_mangle]
94+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
95+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
96+
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
7397
unsafe extern "C" fn const_simd_insert(x: i8x16, e: i8) -> i8x16 {
7498
simd_insert(x, const { 3 + 4 }, e)
7599
}

0 commit comments

Comments
 (0)