|
1 |
| -//@ compile-flags: -O |
| 1 | +//@ compile-flags: -O -Zmerge-functions=disabled |
2 | 2 |
|
3 | 3 | #![feature(core_intrinsics)]
|
| 4 | +#![feature(select_unpredictable)] |
4 | 5 | #![crate_type = "lib"]
|
5 | 6 |
|
| 7 | +/* Test the intrinsic */ |
| 8 | + |
6 | 9 | #[no_mangle]
|
7 | 10 | pub fn test_int(p: bool, a: u64, b: u64) -> u64 {
|
8 | 11 | // CHECK-LABEL: define{{.*}} @test_int
|
@@ -33,3 +36,32 @@ pub fn test_zst(p: bool, a: (), b: ()) -> () {
|
33 | 36 | // CHECK-LABEL: define{{.*}} @test_zst
|
34 | 37 | core::intrinsics::select_unpredictable(p, a, b)
|
35 | 38 | }
|
| 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