Skip to content

Commit d42c3ae

Browse files
committed
Merge the intrinsic and user tests for select_unpredictable
[1] mentions that having a single test with `-Zmerge-functions=disabled` is preferable to having two separate tests. Apply that to the new `select_unpredicatble` test here. [1]: #133964 (comment)
1 parent 1891c28 commit d42c3ae

File tree

2 files changed

+33
-36
lines changed

2 files changed

+33
-36
lines changed

tests/codegen/bool-select-unpredictable.rs

-35
This file was deleted.

tests/codegen/intrinsics/select_unpredictable.rs

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
//@ compile-flags: -O
1+
//@ compile-flags: -O -Zmerge-functions=disabled
22

33
#![feature(core_intrinsics)]
4+
#![feature(select_unpredictable)]
45
#![crate_type = "lib"]
56

7+
/* Test the intrinsic */
8+
69
#[no_mangle]
710
pub fn test_int(p: bool, a: u64, b: u64) -> u64 {
811
// CHECK-LABEL: define{{.*}} @test_int
@@ -33,3 +36,32 @@ pub fn test_zst(p: bool, a: (), b: ()) -> () {
3336
// CHECK-LABEL: define{{.*}} @test_zst
3437
core::intrinsics::select_unpredictable(p, a, b)
3538
}
39+
40+
/* Test the user-facing version */
41+
42+
#[no_mangle]
43+
pub fn test_int2(p: bool, a: u64, b: u64) -> u64 {
44+
// CHECK-LABEL: define{{.*}} @test_int2
45+
// CHECK: select i1 %p, i64 %a, i64 %b, !unpredictable
46+
p.select_unpredictable(a, b)
47+
}
48+
49+
#[no_mangle]
50+
pub fn test_pair2(p: bool, a: (u64, u64), b: (u64, u64)) -> (u64, u64) {
51+
// CHECK-LABEL: define{{.*}} @test_pair2
52+
// CHECK: select i1 %p, {{.*}}, !unpredictable
53+
p.select_unpredictable(a, b)
54+
}
55+
56+
#[no_mangle]
57+
pub fn test_struct2(p: bool, a: Large, b: Large) -> Large {
58+
// CHECK-LABEL: define{{.*}} @test_struct2
59+
// CHECK: select i1 %p, {{.*}}, !unpredictable
60+
p.select_unpredictable(a, b)
61+
}
62+
63+
#[no_mangle]
64+
pub fn test_zst2(p: bool, a: (), b: ()) -> () {
65+
// CHECK-LABEL: define{{.*}} @test_zst2
66+
p.select_unpredictable(a, b)
67+
}

0 commit comments

Comments
 (0)