99#![ crate_type = "lib" ]
1010#![ feature( abi_unadjusted) ]
1111#![ feature( const_trait_impl) ]
12+ #![ feature( link_llvm_intrinsics) ]
1213#![ feature( repr_simd) ]
1314#![ feature( rustc_attrs) ]
1415#![ feature( simd_ffi) ]
@@ -25,19 +26,22 @@ 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 ( a : i8x2 ) -> i8 ;
31+ #[ link_name = "llvm.vector.partial.reduce.add.v2i8.v2i8.v2i8" ]
32+ fn test_i8x2_two_args ( a : i8x2 , b : i8x2 ) -> i8x2 ;
33+ #[ link_name = "llvm.vector.insert.v2i8.v2i8" ]
34+ fn test_i8x2_mixed_args ( a : i8x2 , b : i8x2 , c : usize ) -> i8x2 ;
35+ #[ link_name = "llvm.vector.reduce.fadd.v2f32" ]
36+ fn test_f32x2 ( a : f32 , b : f32x2 ) -> f32 ;
37+ #[ link_name = "llvm.vector.reduce.add.v3i32" ]
38+ fn test_simd_unaligned ( a : Simd < i32 , 3 > ) -> i32 ;
3639}
3740
3841// Ensure the packed variant of the simd struct does not become a const vector
3942// if the size is not a power of 2
40- // CHECK: %"minisimd::PackedSimd<i32, 3>" = type { [3 x i32] }
43+ // FIXME this should use <3 x i32> instead of a struct containing an array
44+ // // COMMENTEDCHECK: %"minisimd::PackedSimd<i32, 3>" = type { [3 x i32] }
4145
4246#[ cfg_attr( target_family = "wasm" , target_feature( enable = "simd128" ) ) ]
4347#[ cfg_attr( target_arch = "arm" , target_feature( enable = "neon" ) ) ]
@@ -46,35 +50,27 @@ extern "unadjusted" {
4650#[ cfg_attr( target_arch = "riscv64" , target_feature( enable = "v" ) ) ]
4751pub fn do_call ( ) {
4852 unsafe {
49- // CHECK: call void @test_i8x2 (<2 x i8> <i8 32, i8 64>
53+ // CHECK: call i8 @llvm.vector.reduce.add.v2i8 (<2 x i8> <i8 32, i8 64>
5054 test_i8x2 ( const { i8x2:: from_array ( [ 32 , 64 ] ) } ) ;
5155
52- // CHECK: call void @test_i8x2_two_args (<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>
56+ // CHECK: call <2 x i8> @llvm.vector.partial.reduce.add.v2i8.v2i8.v2i8 (<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>
5357 test_i8x2_two_args (
5458 const { i8x2:: from_array ( [ 32 , 64 ] ) } ,
5559 const { i8x2:: from_array ( [ 8 , 16 ] ) } ,
5660 ) ;
5761
58- // CHECK: call void @test_i8x2_mixed_args (<2 x i8> <i8 32, i8 64>, i32 43, <2 x i8> <i8 8, i8 16>
62+ // CHECK: call <2 x i8> @llvm.vector.insert.v2i8.v2i8 (<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>, i64 0
5963 test_i8x2_mixed_args (
6064 const { i8x2:: from_array ( [ 32 , 64 ] ) } ,
61- 43 ,
6265 const { i8x2:: from_array ( [ 8 , 16 ] ) } ,
66+ 0 ,
6367 ) ;
6468
65- // CHECK: call void @test_i8x2_arr( <2 x i8 > <i8 32, i8 64 >
66- test_i8x2_arr ( const { i8x2 :: from_array ( [ 32 , 64 ] ) } ) ;
69+ // CHECK: call float @llvm.vector.reduce.fadd.v2f32(float 0.000000e+00, <2 x float > <float 0x3FD47AE140000000, float 0x3FE47AE140000000 >
70+ test_f32x2 ( 0.0 , const { f32x2 :: from_array ( [ 0. 32, 0. 64] ) } ) ;
6771
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 ] ) } ) ;
76-
77- // CHECK: call void @test_simd_unaligned(%"minisimd::PackedSimd<i32, 3>" %1
78- test_simd_unaligned ( const { Simd :: < i32 , 3 > ( [ 2 , 4 , 6 ] ) } ) ;
72+ // FIXME this should use <3 x i32> instead of a struct containing an array
73+ // // COMMENTEDCHECK: call i32 @llvm.vector.reduce.add.v3i32(%"minisimd::PackedSimd<i32, 3>"
74+ // test_simd_unaligned(const { Simd::<i32, 3>([2, 4, 6]) });
7975 }
8076}
0 commit comments