66
77// This test checks that constants of SIMD type are passed as immediate vectors.
88// We ensure that both vector representations (struct with fields and struct wrapping array) work.
9+ #![ allow( non_camel_case_types) ]
910#![ crate_type = "lib" ]
1011#![ feature( abi_unadjusted) ]
12+ #![ feature( arm_target_feature) ]
1113#![ feature( const_trait_impl) ]
14+ #![ feature( link_llvm_intrinsics) ]
15+ #![ feature( mips_target_feature) ]
1216#![ feature( repr_simd) ]
17+ #![ feature( riscv_target_feature) ]
1318#![ feature( rustc_attrs) ]
1419#![ feature( simd_ffi) ]
15- #![ feature( arm_target_feature) ]
16- #![ feature( mips_target_feature) ]
17- #![ allow( non_camel_case_types) ]
18- #![ feature( riscv_target_feature) ]
1920
2021#[ path = "../auxiliary/minisimd.rs" ]
2122mod minisimd;
@@ -25,14 +26,14 @@ use minisimd::{PackedSimd as Simd, f32x2, i8x2};
2526// that they are called with a const vector
2627
2728extern "unadjusted" {
28- fn test_i8x2 ( a : i8x2 ) ;
29- fn test_i8x2_two_args ( a : i8x2 , b : i8x2 ) ;
30- fn test_i8x2_mixed_args ( a : i8x2 , c : i32 , b : i8x2 ) ;
31- fn test_i8x2_arr ( a : i8x2 ) ;
32- fn test_f32x2 ( a : f32x2 ) ;
33- fn test_f32x2_arr ( a : f32x2 ) ;
34- fn test_simd ( a : Simd < i32 , 4 > ) ;
35- fn test_simd_unaligned ( a : Simd < i32 , 3 > ) ;
29+ # [ link_name = "llvm.vector.reduce.add.v2i8" ]
30+ fn test_i8x2_two_args ( a : i8x2 , b : i8x2 ) -> i8 ;
31+ # [ link_name = "llvm.vector.insert.v2i8.i8" ]
32+ fn test_i8x2_mixed_args ( a : i8x2 , b : i8x2 , c : u32 ) ;
33+ # [ link_name = "llvm.vector.reduce.add.v2f32" ]
34+ fn test_f32x2 ( a : f32x2 , b : f32x2 ) -> f32 ;
35+ # [ link_name = "llvm.vector.reduce.add.v3i32" ]
36+ fn test_simd_unaligned ( a : Simd < i32 , 3 > , b : Simd < i32 , 3 > ) -> i32 ;
3637}
3738
3839// Ensure the packed variant of the simd struct does not become a const vector
@@ -46,35 +47,29 @@ extern "unadjusted" {
4647#[ cfg_attr( target_arch = "riscv64" , target_feature( enable = "v" ) ) ]
4748pub fn do_call ( ) {
4849 unsafe {
49- // CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64>
50- test_i8x2 ( const { i8x2:: from_array ( [ 32 , 64 ] ) } ) ;
51-
52- // CHECK: call void @test_i8x2_two_args(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>
50+ // CHECK: call i8 @llvm.vector.reduce.add.v2i8(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>)
5351 test_i8x2_two_args (
5452 const { i8x2:: from_array ( [ 32 , 64 ] ) } ,
5553 const { i8x2:: from_array ( [ 8 , 16 ] ) } ,
5654 ) ;
5755
58- // CHECK: call void @test_i8x2_mixed_args (<2 x i8> <i8 32, i8 64>, i32 43, <2 x i8> <i8 8, i8 16>
56+ // CHECK: call void @llvm.vector.insert.v2i8.i8 (<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>, i32 0)
5957 test_i8x2_mixed_args (
6058 const { i8x2:: from_array ( [ 32 , 64 ] ) } ,
61- 43 ,
6259 const { i8x2:: from_array ( [ 8 , 16 ] ) } ,
60+ 0 ,
6361 ) ;
6462
65- // CHECK: call void @test_i8x2_arr(<2 x i8> <i8 32, i8 64>
66- test_i8x2_arr ( const { i8x2:: from_array ( [ 32 , 64 ] ) } ) ;
67-
68- // CHECK: call void @test_f32x2(<2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>
69- test_f32x2 ( const { f32x2:: from_array ( [ 0.32 , 0.64 ] ) } ) ;
70-
71- // CHECK: void @test_f32x2_arr(<2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>
72- test_f32x2_arr ( const { f32x2:: from_array ( [ 0.32 , 0.64 ] ) } ) ;
73-
74- // CHECK: call void @test_simd(<4 x i32> <i32 2, i32 4, i32 6, i32 8>
75- test_simd ( const { Simd :: < i32 , 4 > ( [ 2 , 4 , 6 , 8 ] ) } ) ;
63+ // CHECK: call float @llvm.vector.reduce.add.v2f32(<2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>, <2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>)
64+ test_f32x2 (
65+ const { f32x2:: from_array ( [ 0.32 , 0.64 ] ) } ,
66+ const { f32x2:: from_array ( [ 0.32 , 0.64 ] ) } ,
67+ ) ;
7668
77- // CHECK: call void @test_simd_unaligned(%"minisimd::PackedSimd<i32, 3>" %1
78- test_simd_unaligned ( const { Simd :: < i32 , 3 > ( [ 2 , 4 , 6 ] ) } ) ;
69+ // CHECK: call i32 @llvm.vector.reduce.add.v3i32(%"minisimd::PackedSimd<i32, 3>"
70+ test_simd_unaligned (
71+ const { Simd :: < i32 , 3 > ( [ 2 , 4 , 6 ] ) } ,
72+ const { Simd :: < i32 , 3 > ( [ 2 , 4 , 6 ] ) } ,
73+ ) ;
7974 }
8075}
0 commit comments