-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as duplicate of#145302
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.
Description
I tried this code:
tests/codegen/simd/scalable.rs
//@ compile-flags: -C opt-level=2
//@ edition: 2021
//@ only-aarch64
#![crate_type = "lib"]
#![allow(incomplete_features, internal_features)]
#![feature(repr_simd, repr_scalable, simd_ffi, link_llvm_intrinsics)]
#[derive(Copy, Clone)]
#[repr(simd, scalable(4))]
#[allow(non_camel_case_types)]
pub struct svint32_t {
_ty: [i32],
}
#[inline(never)]
#[target_feature(enable = "sve")]
pub unsafe fn svdup_n_s32(op: i32) -> svint32_t {
extern "C" {
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.dup.x.nxv4i32")]
fn _svdup_n_s32(op: i32) -> svint32_t;
}
unsafe { _svdup_n_s32(op) }
}
#[inline]
#[target_feature(enable = "sve,sve2")]
pub unsafe fn svxar_n_s32<const IMM3: i32>(op1: svint32_t, op2: svint32_t) -> svint32_t {
extern "C" {
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.xar.nxv4i32")]
fn _svxar_n_s32(op1: svint32_t, op2: svint32_t, imm3: i32) -> svint32_t;
}
unsafe { _svxar_n_s32(op1, op2, IMM3) }
}
#[inline(never)]
#[no_mangle]
#[target_feature(enable = "sve,sve2")]
// 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)
pub unsafe fn pass_as_ref(a: &svint32_t, b: svint32_t) -> svint32_t {
// CHECK: load <vscale x 4 x i32>, ptr %a, align 4
svxar_n_s32::<1>(*a, b)
}
#[no_mangle]
#[target_feature(enable = "sve,sve2")]
// CHECK: define <vscale x 4 x i32> @test()
pub unsafe fn test() -> svint32_t {
let a = svdup_n_s32(1);
let b = svdup_n_s32(2);
// 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)
pass_as_ref(&a, b)
}
I expected to see this happen: All elements in the final output svint32_t vector should have the same value, which is the result of 3 after 1 bit of rotation
Instead, this happened:
cargo rustc --target=aarch64-unknown-linux-gnu -- -C target-feature=+sve
warning: unused manifest key: target.aarch64-unknown-linux-gnu.linker
Compiling scable v0.1.0 (/home/huawei/rust-tests/scable)
error[E0601]: `main` function not found in crate `scable`
--> src/main.rs:53:2
|
53 | }
| ^ consider adding a `main` function to `src/main.rs`
error[E0204]: the trait `Copy` cannot be implemented for this type
--> src/main.rs:9:10
|
9 | #[derive(Copy, Clone)]
| ^^^^
...
13 | _ty: [i32],
| ---------- this field does not implement `Copy`
|
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> src/main.rs:9:16
|
9 | #[derive(Copy, Clone)]
| ^^^^^ doesn't have a size known at compile-time
|
= help: within `svint32_t`, the trait `Sized` is not implemented for `[i32]`, which is required by `svint32_t: Sized`
note: required because it appears within the type `svint32_t`
--> src/main.rs:12:12
|
12 | pub struct svint32_t {
| ^^^^^^^^^
note: required by a bound in `Clone`
--> /home/huawei/rust-b/rust/library/core/src/clone.rs:150:18
|
150 | pub trait Clone: Sized {
| ^^^^^ required by this bound in `Clone`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `[i32]: Clone` is not satisfied
--> src/main.rs:13:5
|
9 | #[derive(Copy, Clone)]
| ----- in this derive macro expansion
...
13 | _ty: [i32],
| ^^^^^^^^^^ the trait `Clone` is not implemented for `[i32]`
|
= help: the trait `Clone` is implemented for `[T; N]`
note: required by a bound in `AssertParamIsClone`
--> /home/huawei/rust-b/rust/library/core/src/clone.rs:196:34
|
196 | pub struct AssertParamIsClone<T: Clone + ?Sized> {
| ^^^^^ required by this bound in `AssertParamIsClone`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
Some errors have detailed explanations: E0204, E0277, E0601.
For more information about an error, try `rustc --explain E0204`.
error: could not compile `scable` (bin "scable") due to 4 previous errors
Meta
rustc --version --verbose
:
rustc 1.82.0-dev
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.