Skip to content

Commit b05795a

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

2 files changed

Lines changed: 27 additions & 36 deletions

File tree

tests/codegen-llvm/const-vector.rs

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#![crate_type = "lib"]
1010
#![feature(abi_unadjusted)]
1111
#![feature(const_trait_impl)]
12+
#![feature(link_llvm_intrinsics)]
1213
#![feature(repr_simd)]
1314
#![feature(rustc_attrs)]
1415
#![feature(simd_ffi)]
@@ -25,19 +26,22 @@ 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(a: i8x2) -> i8;
31+
#[link_name = "llvm.vector.partial.reduce.add.v2i8.v2i8.v2i8"]
32+
fn test_i8x2_two_args(a: i8x2, b: i8x2) -> i8x2;
33+
#[link_name = "llvm.vector.insert.v2i8.v2i8"]
34+
fn test_i8x2_mixed_args(a: i8x2, b: i8x2, c: usize) -> i8x2;
35+
#[link_name = "llvm.vector.reduce.fadd.v2f32"]
36+
fn test_f32x2(a: f32, b: f32x2) -> f32;
37+
#[link_name = "llvm.vector.reduce.add.v3i32"]
38+
fn test_simd_unaligned(a: Simd<i32, 3>) -> i32;
3639
}
3740

3841
// Ensure the packed variant of the simd struct does not become a const vector
3942
// if the size is not a power of 2
40-
// CHECK: %"minisimd::PackedSimd<i32, 3>" = type { [3 x i32] }
43+
// FIXME this should use <3 x i32> instead of a struct containing an array
44+
// // COMMENTEDCHECK: %"minisimd::PackedSimd<i32, 3>" = type { [3 x i32] }
4145

4246
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
4347
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
@@ -46,35 +50,27 @@ extern "unadjusted" {
4650
#[cfg_attr(target_arch = "riscv64", target_feature(enable = "v"))]
4751
pub fn do_call() {
4852
unsafe {
49-
// CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64>
53+
// CHECK: call i8 @llvm.vector.reduce.add.v2i8(<2 x i8> <i8 32, i8 64>
5054
test_i8x2(const { i8x2::from_array([32, 64]) });
5155

52-
// CHECK: call void @test_i8x2_two_args(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>
56+
// CHECK: call <2 x i8> @llvm.vector.partial.reduce.add.v2i8.v2i8.v2i8(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>
5357
test_i8x2_two_args(
5458
const { i8x2::from_array([32, 64]) },
5559
const { i8x2::from_array([8, 16]) },
5660
);
5761

58-
// CHECK: call void @test_i8x2_mixed_args(<2 x i8> <i8 32, i8 64>, i32 43, <2 x i8> <i8 8, i8 16>
62+
// CHECK: call <2 x i8> @llvm.vector.insert.v2i8.v2i8(<2 x i8> <i8 32, i8 64>, <2 x i8> <i8 8, i8 16>, i64 0
5963
test_i8x2_mixed_args(
6064
const { i8x2::from_array([32, 64]) },
61-
43,
6265
const { i8x2::from_array([8, 16]) },
66+
0,
6367
);
6468

65-
// CHECK: call void @test_i8x2_arr(<2 x i8> <i8 32, i8 64>
66-
test_i8x2_arr(const { i8x2::from_array([32, 64]) });
69+
// CHECK: call float @llvm.vector.reduce.fadd.v2f32(float 0.000000e+00, <2 x float> <float 0x3FD47AE140000000, float 0x3FE47AE140000000>
70+
test_f32x2(0.0, const { f32x2::from_array([0.32, 0.64]) });
6771

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]) });
76-
77-
// CHECK: call void @test_simd_unaligned(%"minisimd::PackedSimd<i32, 3>" %1
78-
test_simd_unaligned(const { Simd::<i32, 3>([2, 4, 6]) });
72+
// FIXME this should use <3 x i32> instead of a struct containing an array
73+
// // COMMENTEDCHECK: call i32 @llvm.vector.reduce.add.v3i32(%"minisimd::PackedSimd<i32, 3>"
74+
// test_simd_unaligned(const { Simd::<i32, 3>([2, 4, 6]) });
7975
}
8076
}
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)