Skip to content

Commit d4ba2b4

Browse files
committed
Auto merge of rust-lang#116018 - DianQK:simd-wide-sum-test, r=scottmcm
Increasing the SIMD size improves the vectorization possibilities Change the `simd-wide-sum.rs` to pass tests based on the LLVM main branch. For smaller lengths, we cannot expect to always get vectorized. A related discussion at https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVM.20HEAD.3A.20codegen.2Fsimd.2Fsimd-wide-sum.2Ers.20newly.20failing. r? scottmcm
2 parents ff05789 + e300847 commit d4ba2b4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tests/codegen/simd/simd-wide-sum.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@
1111
#![feature(portable_simd)]
1212

1313
use std::simd::{Simd, SimdUint};
14-
const N: usize = 8;
14+
const N: usize = 16;
1515

1616
#[no_mangle]
1717
// CHECK-LABEL: @wider_reduce_simd
1818
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>
2222
let x: Simd<u16, N> = x.cast();
2323
x.reduce_sum()
2424
}
2525

2626
#[no_mangle]
2727
// CHECK-LABEL: @wider_reduce_loop
2828
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>
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
4141
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>
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
5454
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
5858
x.to_array().into_iter().map(u16::from).sum()
5959
}

0 commit comments

Comments
 (0)