Auto merge of #126163 - RalfJung:simd-packed, r=calebzulawski,workingjubilee
simd packed types: remove outdated comment, extend codegen test It seems like https://github.com/rust-lang/rust/pull/125311 made that check in codegen unnecessary? r? `@workingjubilee` `@calebzulawski`
This commit is contained in:
commit
b3ca6ee18a
@ -1109,10 +1109,12 @@ macro_rules! require_simd {
|
|||||||
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
|
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
|
||||||
let arg_tys = sig.inputs();
|
let arg_tys = sig.inputs();
|
||||||
|
|
||||||
// Vectors must be immediates (non-power-of-2 #[repr(packed)] are not)
|
// Sanity-check: all vector arguments must be immediates.
|
||||||
for (ty, arg) in arg_tys.iter().zip(args) {
|
if cfg!(debug_assertions) {
|
||||||
if ty.is_simd() && !matches!(arg.val, OperandValue::Immediate(_)) {
|
for (ty, arg) in arg_tys.iter().zip(args) {
|
||||||
return_error!(InvalidMonomorphization::SimdArgument { span, name, ty: *ty });
|
if ty.is_simd() {
|
||||||
|
assert!(matches!(arg.val, OperandValue::Immediate(_)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@
|
|||||||
use core::{mem, ptr};
|
use core::{mem, ptr};
|
||||||
|
|
||||||
// Test codegen for not only "packed" but also "fully aligned" SIMD types, and conversion between
|
// Test codegen for not only "packed" but also "fully aligned" SIMD types, and conversion between
|
||||||
// A repr(packed,simd) type with 3 elements can't exceed its element alignment,
|
// them. A repr(packed,simd) type with 3 elements can't exceed its element alignment, whereas the
|
||||||
// whereas the same type as repr(simd) will instead have padding.
|
// same type as repr(simd) will instead have padding.
|
||||||
|
|
||||||
#[repr(simd, packed)]
|
#[repr(simd, packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct Simd<T, const N: usize>([T; N]);
|
pub struct Simd<T, const N: usize>([T; N]);
|
||||||
|
|
||||||
#[repr(simd)]
|
#[repr(simd)]
|
||||||
@ -28,11 +29,11 @@ fn load<T, const N: usize>(v: Simd<T, N>) -> FullSimd<T, N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: square_packed
|
// CHECK-LABEL: square_packed_full
|
||||||
// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align (8|16)]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
|
// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align (8|16)]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
|
||||||
// CHECK-SAME: ptr{{[a-z_ ]*}} align 4
|
// CHECK-SAME: ptr{{[a-z_ ]*}} align 4
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn square_packed(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
|
pub fn square_packed_full(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
|
||||||
// CHECK-NEXT: start
|
// CHECK-NEXT: start
|
||||||
// noopt: alloca [[RET_TYPE]], [[RET_ALIGN]]
|
// noopt: alloca [[RET_TYPE]], [[RET_ALIGN]]
|
||||||
// CHECK: load <3 x float>
|
// CHECK: load <3 x float>
|
||||||
@ -42,3 +43,17 @@ pub fn square_packed(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
|
|||||||
// CHECK-NEXT: ret void
|
// CHECK-NEXT: ret void
|
||||||
unsafe { intrinsics::simd_mul(x, x) }
|
unsafe { intrinsics::simd_mul(x, x) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CHECK-LABEL: square_packed
|
||||||
|
// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align 4]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
|
||||||
|
// CHECK-SAME: ptr{{[a-z_ ]*}} align 4
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn square_packed(x: Simd<f32, 3>) -> Simd<f32, 3> {
|
||||||
|
// CHECK-NEXT: start
|
||||||
|
// CHECK-NEXT: load <3 x float>
|
||||||
|
// noopt-NEXT: load <3 x float>
|
||||||
|
// CHECK-NEXT: [[VREG:%[a-z0-9_]+]] = fmul <3 x float>
|
||||||
|
// CHECK-NEXT: store <3 x float> [[VREG]], ptr [[RET_VREG]], [[RET_ALIGN]]
|
||||||
|
// CHECK-NEXT: ret void
|
||||||
|
unsafe { intrinsics::simd_mul(x, x) }
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user