Skip to content

Commit 243d2ca

Browse files
committed
Auto merge of #135112 - tgross35:combine-select-unpredictable-test, r=the8472
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_unpredictable` test here. [1]: #133964 (comment)
2 parents 13738b0 + 74d2d4b commit 243d2ca

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

tests/codegen/bool-select-unpredictable.rs

-35
This file was deleted.

tests/codegen/intrinsics/select_unpredictable.rs

+38-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
@@ -28,8 +31,42 @@ pub fn test_struct(p: bool, a: Large, b: Large) -> Large {
2831
core::intrinsics::select_unpredictable(p, a, b)
2932
}
3033

34+
// ZSTs should not need a `select` expression.
3135
#[no_mangle]
3236
pub fn test_zst(p: bool, a: (), b: ()) -> () {
3337
// CHECK-LABEL: define{{.*}} @test_zst
38+
// CHECK-NEXT: start:
39+
// CHECK-NEXT: ret void
3440
core::intrinsics::select_unpredictable(p, a, b)
3541
}
42+
43+
/* Test the user-facing version */
44+
45+
#[no_mangle]
46+
pub fn test_int2(p: bool, a: u64, b: u64) -> u64 {
47+
// CHECK-LABEL: define{{.*}} @test_int2
48+
// CHECK: select i1 %p, i64 %a, i64 %b, !unpredictable
49+
p.select_unpredictable(a, b)
50+
}
51+
52+
#[no_mangle]
53+
pub fn test_pair2(p: bool, a: (u64, u64), b: (u64, u64)) -> (u64, u64) {
54+
// CHECK-LABEL: define{{.*}} @test_pair2
55+
// CHECK: select i1 %p, {{.*}}, !unpredictable
56+
p.select_unpredictable(a, b)
57+
}
58+
59+
#[no_mangle]
60+
pub fn test_struct2(p: bool, a: Large, b: Large) -> Large {
61+
// CHECK-LABEL: define{{.*}} @test_struct2
62+
// CHECK: select i1 %p, {{.*}}, !unpredictable
63+
p.select_unpredictable(a, b)
64+
}
65+
66+
#[no_mangle]
67+
pub fn test_zst2(p: bool, a: (), b: ()) -> () {
68+
// CHECK-LABEL: define{{.*}} @test_zst2
69+
// CHECK-NEXT: start:
70+
// CHECK-NEXT: ret void
71+
p.select_unpredictable(a, b)
72+
}

0 commit comments

Comments
 (0)