]> git.lizzy.rs Git - rust.git/blob - tests/codegen/scalar-pair-bool.rs
Rollup merge of #106779 - RReverser:patch-2, r=Mark-Simulacrum
[rust.git] / tests / codegen / scalar-pair-bool.rs
1 // compile-flags: -O
2
3 #![crate_type = "lib"]
4
5 // CHECK: define{{.*}}{ i8, i8 } @pair_bool_bool(i1 noundef zeroext %pair.0, i1 noundef zeroext %pair.1)
6 #[no_mangle]
7 pub fn pair_bool_bool(pair: (bool, bool)) -> (bool, bool) {
8     pair
9 }
10
11 // CHECK: define{{.*}}{ i8, i32 } @pair_bool_i32(i1 noundef zeroext %pair.0, i32 noundef %pair.1)
12 #[no_mangle]
13 pub fn pair_bool_i32(pair: (bool, i32)) -> (bool, i32) {
14     pair
15 }
16
17 // CHECK: define{{.*}}{ i32, i8 } @pair_i32_bool(i32 noundef %pair.0, i1 noundef zeroext %pair.1)
18 #[no_mangle]
19 pub fn pair_i32_bool(pair: (i32, bool)) -> (i32, bool) {
20     pair
21 }
22
23 // CHECK: define{{.*}}{ i8, i8 } @pair_and_or(i1 noundef zeroext %_1.0, i1 noundef zeroext %_1.1)
24 #[no_mangle]
25 pub fn pair_and_or((a, b): (bool, bool)) -> (bool, bool) {
26     // Make sure it can operate directly on the unpacked args
27     // (but it might not be using simple and/or instructions)
28     // CHECK-DAG: %_1.0
29     // CHECK-DAG: %_1.1
30     (a && b, a || b)
31 }
32
33 // CHECK: define{{.*}}void @pair_branches(i1 noundef zeroext %_1.0, i1 noundef zeroext %_1.1)
34 #[no_mangle]
35 pub fn pair_branches((a, b): (bool, bool)) {
36     // Make sure it can branch directly on the unpacked bool args
37     // CHECK: br i1 %_1.0
38     if a {
39         println!("Hello!");
40     }
41     // CHECK: br i1 %_1.1
42     if b {
43         println!("Goodbye!");
44     }
45 }