@@ -9,10 +9,11 @@ use core::intrinsics::simd as intrinsics;
99use core:: { mem, ptr} ;
1010
1111// Test codegen for not only "packed" but also "fully aligned" SIMD types, and conversion between
12- // A repr(packed,simd) type with 3 elements can't exceed its element alignment,
13- // whereas the same type as repr(simd) will instead have padding.
12+ // them. A repr(packed,simd) type with 3 elements can't exceed its element alignment, whereas the
13+ // same type as repr(simd) will instead have padding.
1414
1515#[ repr( simd, packed) ]
16+ #[ derive( Copy , Clone ) ]
1617pub struct Simd < T , const N : usize > ( [ T ; N ] ) ;
1718
1819#[ repr( simd) ]
@@ -28,11 +29,11 @@ fn load<T, const N: usize>(v: Simd<T, N>) -> FullSimd<T, N> {
2829 }
2930}
3031
31- // CHECK-LABEL: square_packed
32+ // CHECK-LABEL: square_packed_full
3233// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align (8|16)]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
3334// CHECK-SAME: ptr{{[a-z_ ]*}} align 4
3435#[ no_mangle]
35- pub fn square_packed ( x : Simd < f32 , 3 > ) -> FullSimd < f32 , 3 > {
36+ pub fn square_packed_full ( x : Simd < f32 , 3 > ) -> FullSimd < f32 , 3 > {
3637 // CHECK-NEXT: start
3738 // noopt: alloca [[RET_TYPE]], [[RET_ALIGN]]
3839 // CHECK: load <3 x float>
@@ -42,3 +43,17 @@ pub fn square_packed(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
4243 // CHECK-NEXT: ret void
4344 unsafe { intrinsics:: simd_mul ( x, x) }
4445}
46+
47+ // CHECK-LABEL: square_packed
48+ // CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align 4]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
49+ // CHECK-SAME: ptr{{[a-z_ ]*}} align 4
50+ #[ no_mangle]
51+ pub fn square_packed ( x : Simd < f32 , 3 > ) -> Simd < f32 , 3 > {
52+ // CHECK-NEXT: start
53+ // CHECK-NEXT: load <3 x float>
54+ // noopt-NEXT: load <3 x float>
55+ // CHECK-NEXT: [[VREG:%[a-z0-9_]+]] = fmul <3 x float>
56+ // CHECK-NEXT: store <3 x float> [[VREG]], ptr [[RET_VREG]], [[RET_ALIGN]]
57+ // CHECK-NEXT: ret void
58+ unsafe { intrinsics:: simd_mul ( x, x) }
59+ }
0 commit comments