]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/scalar-pair-bool.rs
Enable emission of alignment attrs for pointer params
[rust.git] / src / test / codegen / scalar-pair-bool.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -O
12
13 #![crate_type = "lib"]
14
15 // CHECK: define { i8, i8 } @pair_bool_bool(i1 zeroext %pair.0, i1 zeroext %pair.1)
16 #[no_mangle]
17 pub fn pair_bool_bool(pair: (bool, bool)) -> (bool, bool) {
18     pair
19 }
20
21 // CHECK: define { i8, i32 } @pair_bool_i32(i1 zeroext %pair.0, i32 %pair.1)
22 #[no_mangle]
23 pub fn pair_bool_i32(pair: (bool, i32)) -> (bool, i32) {
24     pair
25 }
26
27 // CHECK: define { i32, i8 } @pair_i32_bool(i32 %pair.0, i1 zeroext %pair.1)
28 #[no_mangle]
29 pub fn pair_i32_bool(pair: (i32, bool)) -> (i32, bool) {
30     pair
31 }
32
33 // CHECK: define { i8, i8 } @pair_and_or(i1 zeroext %arg0.0, i1 zeroext %arg0.1)
34 #[no_mangle]
35 pub fn pair_and_or((a, b): (bool, bool)) -> (bool, bool) {
36     // Make sure it can operate directly on the unpacked args
37     // CHECK: and i1 %arg0.0, %arg0.1
38     // CHECK: or i1 %arg0.0, %arg0.1
39     (a && b, a || b)
40 }
41
42 // CHECK: define void @pair_branches(i1 zeroext %arg0.0, i1 zeroext %arg0.1)
43 #[no_mangle]
44 pub fn pair_branches((a, b): (bool, bool)) {
45     // Make sure it can branch directly on the unpacked bool args
46     // CHECK: br i1 %arg0.0
47     if a {
48         println!("Hello!");
49     }
50     // CHECK: br i1 %arg0.1
51     if b {
52         println!("Goodbye!");
53     }
54 }