Skip to content

Commit b3ca6ee

Browse files
committed
Auto merge of rust-lang#126163 - RalfJung:simd-packed, r=calebzulawski,workingjubilee
simd packed types: remove outdated comment, extend codegen test It seems like rust-lang#125311 made that check in codegen unnecessary? r? `@workingjubilee` `@calebzulawski`
2 parents 13423be + 2f2031d commit b3ca6ee

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Diff for: compiler/rustc_codegen_llvm/src/intrinsic.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,12 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11091109
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
11101110
let arg_tys = sig.inputs();
11111111

1112-
// Vectors must be immediates (non-power-of-2 #[repr(packed)] are not)
1113-
for (ty, arg) in arg_tys.iter().zip(args) {
1114-
if ty.is_simd() && !matches!(arg.val, OperandValue::Immediate(_)) {
1115-
return_error!(InvalidMonomorphization::SimdArgument { span, name, ty: *ty });
1112+
// Sanity-check: all vector arguments must be immediates.
1113+
if cfg!(debug_assertions) {
1114+
for (ty, arg) in arg_tys.iter().zip(args) {
1115+
if ty.is_simd() {
1116+
assert!(matches!(arg.val, OperandValue::Immediate(_)));
1117+
}
11161118
}
11171119
}
11181120

Diff for: tests/codegen/simd/packed-simd.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ use core::intrinsics::simd as intrinsics;
99
use core::{mem, ptr};
1010

1111
// Test codegen for not only "packed" but also "fully aligned" SIMD types, and conversion between
12-
// A repr(packed,simd) type with 3 elements can't exceed its element alignment,
13-
// whereas the same type as repr(simd) will instead have padding.
12+
// them. A repr(packed,simd) type with 3 elements can't exceed its element alignment, whereas the
13+
// same type as repr(simd) will instead have padding.
1414

1515
#[repr(simd, packed)]
16+
#[derive(Copy, Clone)]
1617
pub struct Simd<T, const N: usize>([T; N]);
1718

1819
#[repr(simd)]
@@ -28,11 +29,11 @@ fn load<T, const N: usize>(v: Simd<T, N>) -> FullSimd<T, N> {
2829
}
2930
}
3031

31-
// CHECK-LABEL: square_packed
32+
// CHECK-LABEL: square_packed_full
3233
// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align (8|16)]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
3334
// CHECK-SAME: ptr{{[a-z_ ]*}} align 4
3435
#[no_mangle]
35-
pub fn square_packed(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
36+
pub fn square_packed_full(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
3637
// CHECK-NEXT: start
3738
// noopt: alloca [[RET_TYPE]], [[RET_ALIGN]]
3839
// CHECK: load <3 x float>
@@ -42,3 +43,17 @@ pub fn square_packed(x: Simd<f32, 3>) -> FullSimd<f32, 3> {
4243
// CHECK-NEXT: ret void
4344
unsafe { intrinsics::simd_mul(x, x) }
4445
}
46+
47+
// CHECK-LABEL: square_packed
48+
// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align 4]]{{[^%]*}} [[RET_VREG:%[_0-9]*]]
49+
// CHECK-SAME: ptr{{[a-z_ ]*}} align 4
50+
#[no_mangle]
51+
pub fn square_packed(x: Simd<f32, 3>) -> Simd<f32, 3> {
52+
// CHECK-NEXT: start
53+
// CHECK-NEXT: load <3 x float>
54+
// noopt-NEXT: load <3 x float>
55+
// CHECK-NEXT: [[VREG:%[a-z0-9_]+]] = fmul <3 x float>
56+
// CHECK-NEXT: store <3 x float> [[VREG]], ptr [[RET_VREG]], [[RET_ALIGN]]
57+
// CHECK-NEXT: ret void
58+
unsafe { intrinsics::simd_mul(x, x) }
59+
}

0 commit comments

Comments
 (0)