Skip to content

Commit af005a9

Browse files
committed
Fix tests for removal of extern "unadjusted" outside of LLVM intrinsics
1 parent dc13373 commit af005a9

2 files changed

Lines changed: 31 additions & 41 deletions

File tree

tests/codegen-llvm/const-vector.rs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
// This test checks that constants of SIMD type are passed as immediate vectors.
88
// We ensure that both vector representations (struct with fields and struct wrapping array) work.
9+
#![allow(non_camel_case_types)]
910
#![crate_type = "lib"]
1011
#![feature(abi_unadjusted)]
12+
#![feature(arm_target_feature)]
1113
#![feature(const_trait_impl)]
14+
#![feature(link_llvm_intrinsics)]
15+
#![feature(mips_target_feature)]
1216
#![feature(repr_simd)]
17+
#![feature(riscv_target_feature)]
1318
#![feature(rustc_attrs)]
1419
#![feature(simd_ffi)]
15-
#![feature(arm_target_feature)]
16-
#![feature(mips_target_feature)]
17-
#![allow(non_camel_case_types)]
18-
#![feature(riscv_target_feature)]
1920

2021
#[path = "../auxiliary/minisimd.rs"]
2122
mod minisimd;
@@ -25,14 +26,14 @@ use minisimd::{PackedSimd as Simd, f32x2, i8x2};
2526
// that they are called with a const vector
2627

2728
extern "unadjusted" {
28-
fn test_i8x2(a: i8x2);
29-
fn test_i8x2_two_args(a: i8x2, b: i8x2);
30-
fn test_i8x2_mixed_args(a: i8x2, c: i32, b: i8x2);
31-
fn test_i8x2_arr(a: i8x2);
32-
fn test_f32x2(a: f32x2);
33-
fn test_f32x2_arr(a: f32x2);
34-
fn test_simd(a: Simd<i32, 4>);
35-
fn test_simd_unaligned(a: Simd<i32, 3>);
29+
#[link_name = "llvm.vector.reduce.add.v2i8"]
30+
fn test_i8x2_two_args(a: i8x2, b: i8x2) -> i8;
31+
#[link_name = "llvm.vector.insert.v2i8.i8"]
32+
fn test_i8x2_mixed_args(a: i8x2, b: i8x2, c: u32);
33+
#[link_name = "llvm.vector.reduce.add.v2f32"]
34+
fn test_f32x2(a: f32x2, b: f32x2) -> f32;
35+
#[link_name = "llvm.vector.reduce.add.v3i32"]
36+
fn test_simd_unaligned(a: Simd<i32, 3>, b: Simd<i32, 3>) -> i32;
3637
}
3738

3839
// Ensure the packed variant of the simd struct does not become a const vector
@@ -46,35 +47,29 @@ extern "unadjusted" {
4647
#[cfg_attr(target_arch = "riscv64", target_feature(enable = "v"))]
4748
pub fn do_call() {
4849
unsafe {
49-
// CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64>
50-
test_i8x2(const { i8x2::from_array([32, 64]) });
51-
52-
// CHECK: call void @test_i8x2_two_args(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>
50+
// CHECK: call i8 @llvm.vector.reduce.add.v2i8(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>)
5351
test_i8x2_two_args(
5452
const { i8x2::from_array([32, 64]) },
5553
const { i8x2::from_array([8, 16]) },
5654
);
5755

58-
// CHECK: call void @test_i8x2_mixed_args(<2 x i8> <i8 32, i8 64>, i32 43, <2 x i8> <i8 8, i8 16>
56+
// CHECK: call void @llvm.vector.insert.v2i8.i8(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>, i32 0)
5957
test_i8x2_mixed_args(
6058
const { i8x2::from_array([32, 64]) },
61-
43,
6259
const { i8x2::from_array([8, 16]) },
60+
0,
6361
);
6462

65-
// CHECK: call void @test_i8x2_arr(<2 x i8> <i8 32, i8 64>
66-
test_i8x2_arr(const { i8x2::from_array([32, 64]) });
67-
68-
// CHECK: call void @test_f32x2(<2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>
69-
test_f32x2(const { f32x2::from_array([0.32, 0.64]) });
70-
71-
// CHECK: void @test_f32x2_arr(<2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>
72-
test_f32x2_arr(const { f32x2::from_array([0.32, 0.64]) });
73-
74-
// CHECK: call void @test_simd(<4 x i32> <i32 2, i32 4, i32 6, i32 8>
75-
test_simd(const { Simd::<i32, 4>([2, 4, 6, 8]) });
63+
// CHECK: call float @llvm.vector.reduce.add.v2f32(<2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>, <2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>)
64+
test_f32x2(
65+
const { f32x2::from_array([0.32, 0.64]) },
66+
const { f32x2::from_array([0.32, 0.64]) },
67+
);
7668

77-
// CHECK: call void @test_simd_unaligned(%"minisimd::PackedSimd<i32, 3>" %1
78-
test_simd_unaligned(const { Simd::<i32, 3>([2, 4, 6]) });
69+
// CHECK: call i32 @llvm.vector.reduce.add.v3i32(%"minisimd::PackedSimd<i32, 3>"
70+
test_simd_unaligned(
71+
const { Simd::<i32, 3>([2, 4, 6]) },
72+
const { Simd::<i32, 3>([2, 4, 6]) },
73+
);
7974
}
8075
}
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
// Make sure that no 0-sized padding is inserted in structs and that
22
// structs are represented as expected by Neon intrinsics in LLVM.
33
// See #87254.
4+
//@ only-aarch64
45

56
#![crate_type = "lib"]
6-
#![feature(repr_simd, abi_unadjusted)]
77

8-
#[derive(Copy, Clone)]
9-
#[repr(simd)]
10-
pub struct int16x4_t(pub [i16; 4]);
8+
use std::arch::aarch64::{int16x4x2_t, vld1_s16_x2};
119

12-
#[derive(Copy, Clone)]
13-
pub struct int16x4x2_t(pub int16x4_t, pub int16x4_t);
14-
15-
// CHECK: %int16x4x2_t = type { <4 x i16>, <4 x i16> }
1610
#[no_mangle]
17-
extern "unadjusted" fn takes_int16x4x2_t(t: int16x4x2_t) -> int16x4x2_t {
18-
t
11+
unsafe extern "C" fn returns_int16x4x2_t(a: *const i16) -> int16x4x2_t {
12+
// CHECK: call { <4 x i16>, <4 x i16> } @llvm.aarch64.neon.ld1x2.v4i16.p0
13+
vld1_s16_x2(a)
1914
}

0 commit comments

Comments
 (0)