Skip to content

Commit b8b2b8d

Browse files
committed
Add assembly tests for simd_reduce_all/simd_reduce_any on x86_64 and aarch64
1 parent 55ca959 commit b8b2b8d

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// verify that simd mask reductions do not introduce additional bit shift operations
2+
3+
// assembly-output: emit-asm
4+
// compile-flags: --crate-type=lib -O --target aarch64-unknown-linux-gnu
5+
// needs-llvm-components: aarch64
6+
// only-aarch64
7+
// only-linux
8+
9+
#![feature(repr_simd, platform_intrinsics)]
10+
#![allow(non_camel_case_types)]
11+
12+
#[repr(simd)]
13+
#[derive(Copy, Clone)]
14+
pub struct mask8x16([i8; 16]);
15+
16+
extern "platform-intrinsic" {
17+
fn simd_reduce_all<T>(x: T) -> bool;
18+
fn simd_reduce_any<T>(x: T) -> bool;
19+
}
20+
21+
// CHECK-LABEL: mask_reduce_all:
22+
#[no_mangle]
23+
pub unsafe fn mask_reduce_all(m: mask8x16) -> bool {
24+
// CHECK: umaxv
25+
simd_reduce_all(m)
26+
}
27+
28+
// CHECK-LABEL: mask_reduce_any:
29+
#[no_mangle]
30+
pub unsafe fn mask_reduce_any(m: mask8x16) -> bool {
31+
// CHECK: umaxv
32+
simd_reduce_any(m)
33+
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// verify that simd mask reductions do not introduce additional bit shift operations
2+
3+
// assembly-output: emit-asm
4+
// compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
5+
// only-x86_64
6+
7+
#![feature(repr_simd, platform_intrinsics)]
8+
#![allow(non_camel_case_types)]
9+
10+
#[repr(simd)]
11+
#[derive(Copy, Clone)]
12+
pub struct mask8x16([i8; 16]);
13+
14+
extern "platform-intrinsic" {
15+
fn simd_reduce_all<T>(x: T) -> bool;
16+
fn simd_reduce_any<T>(x: T) -> bool;
17+
}
18+
19+
// CHECK-LABEL: mask_reduce_all:
20+
#[no_mangle]
21+
pub unsafe fn mask_reduce_all(m: mask8x16) -> bool {
22+
// CHECK-NOT: psllw
23+
// CHECK: pmovmskb
24+
simd_reduce_all(m)
25+
}
26+
27+
// CHECK-LABEL: mask_reduce_any:
28+
#[no_mangle]
29+
pub unsafe fn mask_reduce_any(m: mask8x16) -> bool {
30+
// CHECK-NOT: psllw
31+
// CHECK: pmovmskb
32+
simd_reduce_any(m)
33+
}

0 commit comments

Comments
 (0)