11
11
#![ feature( portable_simd) ]
12
12
13
13
use std:: simd:: { Simd , SimdUint } ;
14
- const N : usize = 8 ;
14
+ const N : usize = 16 ;
15
15
16
16
#[ no_mangle]
17
17
// CHECK-LABEL: @wider_reduce_simd
18
18
pub fn wider_reduce_simd ( x : Simd < u8 , N > ) -> u16 {
19
- // CHECK: zext <8 x i8>
20
- // CHECK-SAME: to <8 x i16>
21
- // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
19
+ // CHECK: zext <16 x i8>
20
+ // CHECK-SAME: to <16 x i16>
21
+ // CHECK: call i16 @llvm.vector.reduce.add.v16i16(<16 x i16>
22
22
let x: Simd < u16 , N > = x. cast ( ) ;
23
23
x. reduce_sum ( )
24
24
}
25
25
26
26
#[ no_mangle]
27
27
// CHECK-LABEL: @wider_reduce_loop
28
28
pub fn wider_reduce_loop ( x : Simd < u8 , N > ) -> u16 {
29
- // CHECK: zext <8 x i8>
30
- // CHECK-SAME: to <8 x i16>
31
- // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
29
+ // CHECK: zext <16 x i8>
30
+ // CHECK-SAME: to <16 x i16>
31
+ // CHECK: call i16 @llvm.vector.reduce.add.v16i16(<16 x i16>
32
32
let mut sum = 0_u16 ;
33
33
for i in 0 ..N {
34
34
sum += u16:: from ( x[ i] ) ;
@@ -39,9 +39,9 @@ pub fn wider_reduce_loop(x: Simd<u8, N>) -> u16 {
39
39
#[ no_mangle]
40
40
// CHECK-LABEL: @wider_reduce_iter
41
41
pub fn wider_reduce_iter ( x : Simd < u8 , N > ) -> u16 {
42
- // CHECK: zext <8 x i8>
43
- // CHECK-SAME: to <8 x i16>
44
- // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
42
+ // CHECK: zext <16 x i8>
43
+ // CHECK-SAME: to <16 x i16>
44
+ // CHECK: call i16 @llvm.vector.reduce.add.v16i16(<16 x i16>
45
45
x. as_array ( ) . iter ( ) . copied ( ) . map ( u16:: from) . sum ( )
46
46
}
47
47
@@ -52,8 +52,8 @@ pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
52
52
#[ no_mangle]
53
53
// CHECK-LABEL: @wider_reduce_into_iter
54
54
pub fn wider_reduce_into_iter ( x : Simd < u8 , N > ) -> u16 {
55
- // CHECK: zext <8 x i8>
56
- // CHECK-SAME: to <8 x i16>
57
- // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
55
+ // FIXME: It would be nice if this was exactly the same as the above tests,
56
+ // but at the time of writing this comment, that didn't happen on LLVM main.
57
+ // CHECK: call i16 @llvm.vector.reduce.add
58
58
x. to_array ( ) . into_iter ( ) . map ( u16:: from) . sum ( )
59
59
}
0 commit comments