|
| 1 | +//@ only-aarch64 |
| 2 | +//@ compile-flags: -C opt-level=2 --edition=2021 |
| 3 | + |
| 4 | +#![crate_type = "lib"] |
| 5 | + |
| 6 | +#![allow(incomplete_features, internal_features, improper_ctypes)] |
| 7 | +#![feature( |
| 8 | + repr_simd, |
| 9 | + repr_scalable, |
| 10 | + simd_ffi, |
| 11 | + unsized_locals, |
| 12 | + unsized_fn_params, |
| 13 | + link_llvm_intrinsics |
| 14 | +)] |
| 15 | + |
| 16 | +#[repr(simd, scalable(4))] |
| 17 | +#[allow(non_camel_case_types)] |
| 18 | +pub struct svint32_t { |
| 19 | + _ty: [i32], |
| 20 | +} |
| 21 | + |
| 22 | +#[inline(never)] |
| 23 | +#[target_feature(enable = "sve")] |
| 24 | +pub unsafe fn svdup_n_s32(op: i32) -> svint32_t { |
| 25 | + extern "C" { |
| 26 | + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.dup.x.nxv4i32")] |
| 27 | + fn _svdup_n_s32(op: i32) -> svint32_t; |
| 28 | + } |
| 29 | + unsafe { _svdup_n_s32(op) } |
| 30 | +} |
| 31 | + |
| 32 | +#[inline] |
| 33 | +#[target_feature(enable = "sve,sve2")] |
| 34 | +pub unsafe fn svxar_n_s32<const IMM3: i32>(op1: svint32_t, op2: svint32_t) -> svint32_t { |
| 35 | + extern "C" { |
| 36 | + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.xar.nxv4i32")] |
| 37 | + fn _svxar_n_s32(op1: svint32_t, op2: svint32_t, imm3: i32) -> svint32_t; |
| 38 | + } |
| 39 | + unsafe { _svxar_n_s32(op1, op2, IMM3) } |
| 40 | +} |
| 41 | + |
| 42 | +#[inline(never)] |
| 43 | +#[no_mangle] |
| 44 | +#[target_feature(enable = "sve,sve2")] |
| 45 | +// CHECK: define <vscale x 4 x i32> @pass_as_ref(ptr noalias nocapture noundef readonly align 4 dereferenceable(4) %a, <vscale x 4 x i32> %b) |
| 46 | +pub unsafe fn pass_as_ref(a: &svint32_t, b: svint32_t) -> svint32_t { |
| 47 | + // CHECK: load <vscale x 4 x i32>, ptr %a, align 4 |
| 48 | + svxar_n_s32::<1>(*a, b) |
| 49 | +} |
| 50 | + |
| 51 | +#[no_mangle] |
| 52 | +#[target_feature(enable = "sve,sve2")] |
| 53 | +// CHECK: define <vscale x 4 x i32> @test() |
| 54 | +pub unsafe fn test() -> svint32_t { |
| 55 | + let a = svdup_n_s32(1); |
| 56 | + let b = svdup_n_s32(2); |
| 57 | + // CHECK: call <vscale x 4 x i32> @pass_as_ref(ptr noalias noundef nonnull readonly align 4 dereferenceable(4) %a, <vscale x 4 x i32> %b) |
| 58 | + pass_as_ref(&a, b) |
| 59 | +} |
0 commit comments