2024-02-22 06:10:29 -06:00
|
|
|
//@ ignore-emscripten vectors passed directly
|
|
|
|
//@ compile-flags: -O -C no-prepopulate-passes
|
2024-07-03 07:41:36 -05:00
|
|
|
// 32-bit x86 returns `f32` differently to avoid the x87 stack.
|
|
|
|
//@ revisions: x86 other
|
|
|
|
//@[x86] only-x86
|
|
|
|
//@[other] ignore-x86
|
2018-11-08 13:12:05 -06:00
|
|
|
|
|
|
|
// This test that using union forward the abi of the inner type, as
|
|
|
|
// discussed in #54668
|
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
#![crate_type = "lib"]
|
2018-11-08 13:12:05 -06:00
|
|
|
#![feature(repr_simd)]
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub enum Unhab {}
|
|
|
|
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
2024-08-22 03:28:20 -05:00
|
|
|
pub struct i64x4([i64; 4]);
|
2018-11-08 13:12:05 -06:00
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionI64x4 {
|
|
|
|
a: (),
|
|
|
|
b: i64x4,
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}void @test_UnionI64x4(ptr {{.*}} %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionI64x4(_: UnionI64x4) {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub union UnionI64x4_ {
|
|
|
|
a: i64x4,
|
|
|
|
b: (),
|
|
|
|
c: i64x4,
|
|
|
|
d: Unhab,
|
|
|
|
e: ((), ()),
|
|
|
|
f: UnionI64x4,
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_(ptr {{.*}} %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionI64x4_(_: UnionI64x4_) {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionI64x4I64 {
|
|
|
|
a: i64x4,
|
|
|
|
b: i64,
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64(ptr {{.*}} %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionI64x4I64(_: UnionI64x4I64) {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionI64x4Tuple {
|
|
|
|
a: i64x4,
|
|
|
|
b: (i64, i64, i64, i64),
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple(ptr {{.*}} %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionF32 {
|
|
|
|
a: f32,
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-07-03 07:41:36 -05:00
|
|
|
// other: define {{(dso_local )?}}float @test_UnionF32(float %_1)
|
|
|
|
// x86: define {{(dso_local )?}}i32 @test_UnionF32(float %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionF32(_: UnionF32) -> UnionF32 {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionF32F32 {
|
|
|
|
a: f32,
|
|
|
|
b: f32,
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-07-03 07:41:36 -05:00
|
|
|
// other: define {{(dso_local )?}}float @test_UnionF32F32(float %_1)
|
|
|
|
// x86: define {{(dso_local )?}}i32 @test_UnionF32F32(float %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionF32U32 {
|
|
|
|
a: f32,
|
|
|
|
b: u32,
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2023-05-23 08:26:31 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}i32 @test_UnionF32U32(i32{{( %0)?}})
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionU128 {
|
|
|
|
a: u128,
|
|
|
|
}
|
2023-05-23 08:26:31 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}i128 @test_UnionU128(i128 %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionU128(_: UnionU128) -> UnionU128 {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
|
|
|
#[repr(C)]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union CUnionU128 {
|
|
|
|
a: u128,
|
|
|
|
}
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}void @test_CUnionU128(ptr {{.*}} %_1)
|
2018-11-08 13:12:05 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_CUnionU128(_: CUnionU128) {
|
|
|
|
loop {}
|
|
|
|
}
|
2018-11-08 13:12:05 -06:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
pub union UnionBool {
|
|
|
|
b: bool,
|
|
|
|
}
|
2023-05-23 08:26:31 -05:00
|
|
|
// CHECK: define {{(dso_local )?}}noundef zeroext i1 @test_UnionBool(i8 %b)
|
2018-11-20 05:14:53 -06:00
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test_UnionBool(b: UnionBool) -> bool {
|
|
|
|
unsafe { b.b }
|
|
|
|
}
|
2023-05-15 14:15:28 -05:00
|
|
|
// CHECK: %_0 = trunc i8 %b to i1
|