2021-04-03 06:05:11 -05:00
|
|
|
//
|
2019-07-13 10:16:57 -05:00
|
|
|
// compile-flags: -C no-prepopulate-passes
|
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
2020-11-12 22:31:12 -06:00
|
|
|
#![allow(non_camel_case_types)]
|
2023-04-01 03:46:36 -05:00
|
|
|
#![feature(repr_simd, platform_intrinsics)]
|
|
|
|
#![feature(inline_const)]
|
2019-07-13 10:16:57 -05:00
|
|
|
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct S<const N: usize>([f32; N]);
|
|
|
|
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct T([f32; 4]);
|
|
|
|
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct U(f32, f32, f32, f32);
|
|
|
|
|
2023-04-01 03:46:36 -05:00
|
|
|
// CHECK-LABEL: @array_align(
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn array_align() -> usize {
|
|
|
|
// CHECK: ret [[USIZE:i[0-9]+]] [[ARRAY_ALIGN:[0-9]+]]
|
|
|
|
const { std::mem::align_of::<f32>() }
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @vector_align(
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn vector_align() -> usize {
|
|
|
|
// CHECK: ret [[USIZE]] [[VECTOR_ALIGN:[0-9]+]]
|
|
|
|
const { std::mem::align_of::<U>() }
|
|
|
|
}
|
|
|
|
|
2019-07-13 10:16:57 -05:00
|
|
|
// CHECK-LABEL: @build_array_s
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn build_array_s(x: [f32; 4]) -> S<4> {
|
2023-04-01 03:46:36 -05:00
|
|
|
// CHECK: call void @llvm.memcpy.{{.+}}({{.*}} align [[VECTOR_ALIGN]] {{.*}} align [[ARRAY_ALIGN]] {{.*}}, [[USIZE]] 16, i1 false)
|
2019-07-13 10:16:57 -05:00
|
|
|
S::<4>(x)
|
|
|
|
}
|
|
|
|
|
2023-04-01 03:46:36 -05:00
|
|
|
// CHECK-LABEL: @build_array_transmute_s
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn build_array_transmute_s(x: [f32; 4]) -> S<4> {
|
|
|
|
// CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]]
|
|
|
|
// CHECK: store <4 x float> %[[VAL:.+]], {{ptr %0|.+>\* %.+}}, align [[VECTOR_ALIGN]]
|
|
|
|
unsafe { std::mem::transmute(x) }
|
|
|
|
}
|
|
|
|
|
2019-07-13 10:16:57 -05:00
|
|
|
// CHECK-LABEL: @build_array_t
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn build_array_t(x: [f32; 4]) -> T {
|
2023-04-01 03:46:36 -05:00
|
|
|
// CHECK: call void @llvm.memcpy.{{.+}}({{.*}} align [[VECTOR_ALIGN]] {{.*}} align [[ARRAY_ALIGN]] {{.*}}, [[USIZE]] 16, i1 false)
|
2019-07-13 10:16:57 -05:00
|
|
|
T(x)
|
|
|
|
}
|
|
|
|
|
2023-04-01 03:46:36 -05:00
|
|
|
// CHECK-LABEL: @build_array_transmute_t
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn build_array_transmute_t(x: [f32; 4]) -> T {
|
|
|
|
// CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]]
|
|
|
|
// CHECK: store <4 x float> %[[VAL:.+]], {{ptr %0|.+>\* %.+}}, align [[VECTOR_ALIGN]]
|
|
|
|
unsafe { std::mem::transmute(x) }
|
|
|
|
}
|
|
|
|
|
2019-07-13 10:16:57 -05:00
|
|
|
// CHECK-LABEL: @build_array_u
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn build_array_u(x: [f32; 4]) -> U {
|
2023-04-01 03:46:36 -05:00
|
|
|
// CHECK: store float %a, {{.+}}, align [[VECTOR_ALIGN]]
|
|
|
|
// CHECK: store float %b, {{.+}}, align [[ARRAY_ALIGN]]
|
|
|
|
// CHECK: store float %c, {{.+}}, align
|
|
|
|
// CHECK: store float %d, {{.+}}, align [[ARRAY_ALIGN]]
|
|
|
|
let [a, b, c, d] = x;
|
|
|
|
U(a, b, c, d)
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @build_array_transmute_u
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn build_array_transmute_u(x: [f32; 4]) -> U {
|
|
|
|
// CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]]
|
|
|
|
// CHECK: store <4 x float> %[[VAL:.+]], {{ptr %0|.+>\* %.+}}, align [[VECTOR_ALIGN]]
|
2019-07-13 10:16:57 -05:00
|
|
|
unsafe { std::mem::transmute(x) }
|
|
|
|
}
|