1111#![ feature( portable_simd) ]
1212
1313use std:: simd:: { Simd , SimdUint } ;
14- const N : usize = 8 ;
14+ const N : usize = 16 ;
1515
1616#[ no_mangle]
1717// CHECK-LABEL: @wider_reduce_simd
1818pub 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>
2222 let x: Simd < u16 , N > = x. cast ( ) ;
2323 x. reduce_sum ( )
2424}
2525
2626#[ no_mangle]
2727// CHECK-LABEL: @wider_reduce_loop
2828pub 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>
3232 let mut sum = 0_u16 ;
3333 for i in 0 ..N {
3434 sum += u16:: from ( x[ i] ) ;
@@ -39,9 +39,9 @@ pub fn wider_reduce_loop(x: Simd<u8, N>) -> u16 {
3939#[ no_mangle]
4040// CHECK-LABEL: @wider_reduce_iter
4141pub 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>
4545 x. as_array ( ) . iter ( ) . copied ( ) . map ( u16:: from) . sum ( )
4646}
4747
@@ -52,8 +52,8 @@ pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
5252#[ no_mangle]
5353// CHECK-LABEL: @wider_reduce_into_iter
5454pub 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
5858 x. to_array ( ) . into_iter ( ) . map ( u16:: from) . sum ( )
5959}
0 commit comments