|
| 1 | +//@ compile-flags: -Copt-level=0 |
| 2 | +//@ only-aarch64 |
| 3 | +#![allow(incomplete_features, internal_features, improper_ctypes, private_interfaces, unused)] |
| 4 | +#![crate_type = "bin"] |
| 5 | +#![feature( |
| 6 | + core_intrinsics, |
| 7 | + simd_ffi, |
| 8 | + rustc_attrs, |
| 9 | + target_feature_inline_always, |
| 10 | + abi_unadjusted, |
| 11 | + link_llvm_intrinsics |
| 12 | +)] |
| 13 | + |
| 14 | +use std::arch::aarch64::int8x16_t; |
| 15 | +use std::mem::transmute; |
| 16 | + |
| 17 | +// Test that the use of the `sve_undef` intrinsic produces the expected LLVM IR that will not |
| 18 | +// segfault at runtime. |
| 19 | + |
| 20 | +#[rustc_scalable_vector(16)] |
| 21 | +#[allow(non_camel_case_types)] |
| 22 | +struct svint8_t(i8); |
| 23 | + |
| 24 | +#[inline(always)] |
| 25 | +#[target_feature(enable = "sve")] |
| 26 | +pub unsafe fn svundef_s8() -> svint8_t { |
| 27 | + std::intrinsics::scalable::sve_undef() |
| 28 | +} |
| 29 | + |
| 30 | +// CHECK: ; sve_undef::test_ffr |
| 31 | +// CHECK: %[[L1:[_.i0-9]+]] = alloca <vscale x 16 x i8>, align 16 |
| 32 | +// CHECK: %{{.*}} = alloca [16 x i8], align 1 |
| 33 | +// CHECK: store <vscale x 16 x i8> poison, ptr %[[L1]], align 16 |
| 34 | +// CHECK: %[[L2:[_.i0-9]+]] = load <vscale x 16 x i8>, ptr %[[L1]], align 16 |
| 35 | +// CHECK: %{{.*}} = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v16i8(<vscale x 16 x i8> %[[L2]], <16 x i8> %{{.*}}, i64 0) |
| 36 | + |
| 37 | +#[inline(always)] |
| 38 | +#[target_feature(enable = "sve")] |
| 39 | +pub fn svdupq_n_s8( |
| 40 | + x0: i8, |
| 41 | + x1: i8, |
| 42 | + x2: i8, |
| 43 | + x3: i8, |
| 44 | + x4: i8, |
| 45 | + x5: i8, |
| 46 | + x6: i8, |
| 47 | + x7: i8, |
| 48 | + x8: i8, |
| 49 | + x9: i8, |
| 50 | + x10: i8, |
| 51 | + x11: i8, |
| 52 | + x12: i8, |
| 53 | + x13: i8, |
| 54 | + x14: i8, |
| 55 | + x15: i8, |
| 56 | +) -> svint8_t { |
| 57 | + unsafe extern "unadjusted" { |
| 58 | + #[cfg_attr( |
| 59 | + target_arch = "aarch64", |
| 60 | + link_name = "llvm.experimental.vector.insert.nxv16i8.v16i8" |
| 61 | + )] |
| 62 | + fn _svdupq_n_s8(op0: svint8_t, op1: int8x16_t, idx: i64) -> svint8_t; |
| 63 | + } |
| 64 | + unsafe { |
| 65 | + _svdupq_n_s8( |
| 66 | + svundef_s8(), |
| 67 | + transmute([x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15]), |
| 68 | + 0, |
| 69 | + ) |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +#[target_feature(enable = "sve")] |
| 74 | +unsafe fn test_ffr() { |
| 75 | + svdupq_n_s8(1i8, 0i8, 1i8, 0i8, 1i8, 0i8, 1i8, 0i8, 1i8, 0i8, 1i8, 0i8, 1i8, 0i8, 1i8, 0i8); |
| 76 | +} |
| 77 | + |
| 78 | +fn main() { |
| 79 | + unsafe { test_ffr() } |
| 80 | +} |
0 commit comments