Skip to content

Commit 65d8a21

Browse files
committed
Adjust gather, scatter and select codegen tests
1 parent f07cbd1 commit 65d8a21

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ extern "rust-intrinsic" {
2323
#[no_mangle]
2424
pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2<i32>,
2525
values: Vec2<f32>) -> Vec2<f32> {
26-
// CHECK: call <2 x float> @llvm.masked.gather.v2f32.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}})
26+
// CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, <i32 31, i32 31>
27+
// CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
28+
// CHECK: call <2 x float> @llvm.masked.gather.v2f32.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]], <2 x float> {{.*}})
2729
simd_gather(values, pointers, mask)
2830
}
2931

3032
// CHECK-LABEL: @gather_pf32x2
3133
#[no_mangle]
3234
pub unsafe fn gather_pf32x2(pointers: Vec2<*const *const f32>, mask: Vec2<i32>,
3335
values: Vec2<*const f32>) -> Vec2<*const f32> {
34-
// CHECK: call <2 x ptr> @llvm.masked.gather.v2p0.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x ptr> {{.*}})
36+
// CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, <i32 31, i32 31>
37+
// CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
38+
// CHECK: call <2 x ptr> @llvm.masked.gather.v2p0.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]], <2 x ptr> {{.*}})
3539
simd_gather(values, pointers, mask)
3640
}

tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ extern "rust-intrinsic" {
2323
#[no_mangle]
2424
pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2<i32>,
2525
values: Vec2<f32>) {
26-
// CHECK: call void @llvm.masked.scatter.v2f32.v2p0(<2 x float> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}})
26+
// CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, <i32 31, i32 31>
27+
// CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
28+
// CHECK: call void @llvm.masked.scatter.v2f32.v2p0(<2 x float> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]]
2729
simd_scatter(values, pointers, mask)
2830
}
2931

@@ -32,6 +34,8 @@ pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2<i32>,
3234
#[no_mangle]
3335
pub unsafe fn scatter_pf32x2(pointers: Vec2<*mut *const f32>, mask: Vec2<i32>,
3436
values: Vec2<*const f32>) {
35-
// CHECK: call void @llvm.masked.scatter.v2p0.v2p0(<2 x ptr> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}})
37+
// CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, <i32 31, i32 31>
38+
// CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
39+
// CHECK: call void @llvm.masked.scatter.v2p0.v2p0(<2 x ptr> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]]
3640
simd_scatter(values, pointers, mask)
3741
}

tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,48 @@
66
#[allow(non_camel_case_types)]
77

88
#[repr(simd)]
9-
#[derive(Copy, Clone, PartialEq, Debug)]
9+
#[derive(Copy, Clone)]
1010
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
1111

1212
#[repr(simd)]
13-
#[derive(Copy, Clone, PartialEq, Debug)]
13+
#[derive(Copy, Clone)]
1414
pub struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32);
1515

1616
#[repr(simd)]
17-
#[derive(Copy, Clone, PartialEq, Debug)]
18-
pub struct b8x4(pub i8, pub i8, pub i8, pub i8);
17+
#[derive(Copy, Clone)]
18+
pub struct m8x4(pub i8, pub i8, pub i8, pub i8);
19+
20+
#[repr(simd)]
21+
#[derive(Copy, Clone)]
22+
pub struct m32x4(pub i32, pub i32, pub i32, pub i32);
1923

2024
extern "rust-intrinsic" {
2125
fn simd_select<T, U>(x: T, a: U, b: U) -> U;
2226
fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
2327
}
2428

25-
// CHECK-LABEL: @select
29+
// CHECK-LABEL: @select_m8
2630
#[no_mangle]
27-
pub unsafe fn select(m: b8x4, a: f32x4, b: f32x4) -> f32x4 {
31+
pub unsafe fn select_m8(m: m8x4, a: f32x4, b: f32x4) -> f32x4 {
2832
// CHECK: [[A:%[0-9]+]] = lshr <4 x i8> %{{m|1}}, <i8 7, i8 7, i8 7, i8 7>
2933
// CHECK: [[B:%[0-9]+]] = trunc <4 x i8> [[A]] to <4 x i1>
3034
// CHECK: select <4 x i1> [[B]]
3135
simd_select(m, a, b)
3236
}
3337

38+
// CHECK-LABEL: @select_m32
39+
#[no_mangle]
40+
pub unsafe fn select_m32(m: m32x4, a: f32x4, b: f32x4) -> f32x4 {
41+
// CHECK: [[A:%[0-9]+]] = lshr <4 x i32> %{{m|1}}, <i32 31, i32 31, i32 31, i32 31>
42+
// CHECK: [[B:%[0-9]+]] = trunc <4 x i32> [[A]] to <4 x i1>
43+
// CHECK: select <4 x i1> [[B]]
44+
simd_select(m, a, b)
45+
}
46+
3447
// CHECK-LABEL: @select_bitmask
3548
#[no_mangle]
3649
pub unsafe fn select_bitmask(m: i8, a: f32x8, b: f32x8) -> f32x8 {
37-
// CHECK: select <8 x i1>
50+
// CHECK: [[A:%[0-9]+]] = bitcast i8 {{.*}} to <8 x i1>
51+
// CHECK: select <8 x i1> [[A]]
3852
simd_select_bitmask(m, a, b)
3953
}

0 commit comments

Comments
 (0)