]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/lower_128bit_debug_test.rs
40acf048aba018e142695f175da965bba440b801
[rust.git] / src / test / mir-opt / lower_128bit_debug_test.rs
1 // Copyright 2017 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 // asmjs can't even pass i128 as arguments or return values, so ignore it.
12 // this will hopefully be fixed by the LLVM 5 upgrade (#43370)
13 // ignore-asmjs
14
15 // compile-flags: -Z lower_128bit_ops -C debug_assertions=yes
16
17 #![feature(i128_type)]
18
19 fn test_signed(mut x: i128) -> i128 {
20     x += 1;
21     x -= 2;
22     x *= 3;
23     x /= 4;
24     x %= 5;
25     x <<= 6;
26     x >>= 7;
27     x
28 }
29
30 fn test_unsigned(mut x: u128) -> u128 {
31     x += 1;
32     x -= 2;
33     x *= 3;
34     x /= 4;
35     x %= 5;
36     x <<= 6;
37     x >>= 7;
38     x
39 }
40
41 fn main() {
42     assert_eq!(test_signed(-222), -1);
43     assert_eq!(test_unsigned(200), 2);
44 }
45
46 // END RUST SOURCE
47
48 // START rustc.test_signed.Lower128Bit.after.mir
49 //     _2 = const compiler_builtins::int::addsub::rust_i128_addo(_1, const 1i128) -> bb10;
50 //     ...
51 //     _1 = move (_2.0: i128);
52 //     _3 = const compiler_builtins::int::addsub::rust_i128_subo(_1, const 2i128) -> bb11;
53 //     ...
54 //     _1 = move (_3.0: i128);
55 //     _4 = const compiler_builtins::int::mul::rust_i128_mulo(_1, const 3i128) -> bb12;
56 //     ...
57 //     _1 = move (_4.0: i128);
58 //     ...
59 //     _1 = const compiler_builtins::int::sdiv::rust_i128_div(_1, const 4i128) -> bb13;
60 //     ...
61 //     _1 = const compiler_builtins::int::sdiv::rust_i128_rem(_1, const 5i128) -> bb15;
62 //     ...
63 //     _1 = move (_13.0: i128);
64 //     ...
65 //     _17 = const 7i32 as u128 (Misc);
66 //     _14 = const compiler_builtins::int::shift::rust_i128_shro(_1, move _17) -> bb16;
67 //     ...
68 //     _1 = move (_14.0: i128);
69 //     ...
70 //     assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1;
71 //     ...
72 //     assert(!move (_3.1: bool), "attempt to subtract with overflow") -> bb2;
73 //     ...
74 //     assert(!move (_4.1: bool), "attempt to multiply with overflow") -> bb3;
75 //     ...
76 //     assert(!move (_13.1: bool), "attempt to shift left with overflow") -> bb8;
77 //     ...
78 //     _16 = const 6i32 as u128 (Misc);
79 //     _13 = const compiler_builtins::int::shift::rust_i128_shlo(_1, move _16) -> bb14;
80 //     ...
81 //     assert(!move (_14.1: bool), "attempt to shift right with overflow") -> bb9;
82 // END rustc.test_signed.Lower128Bit.after.mir
83
84 // START rustc.test_unsigned.Lower128Bit.after.mir
85 //     _2 = const compiler_builtins::int::addsub::rust_u128_addo(_1, const 1u128) -> bb8;
86 //     ...
87 //     _1 = move (_2.0: u128);
88 //     _3 = const compiler_builtins::int::addsub::rust_u128_subo(_1, const 2u128) -> bb9;
89 //     ...
90 //     _1 = move (_3.0: u128);
91 //     _4 = const compiler_builtins::int::mul::rust_u128_mulo(_1, const 3u128) -> bb10;
92 //     ...
93 //     _1 = move (_4.0: u128);
94 //     ...
95 //     _1 = const compiler_builtins::int::udiv::rust_u128_div(_1, const 4u128) -> bb11;
96 //     ...
97 //     _1 = const compiler_builtins::int::udiv::rust_u128_rem(_1, const 5u128) -> bb13;
98 //     ...
99 //     _1 = move (_7.0: u128);
100 //     ...
101 //     _11 = const 7i32 as u128 (Misc);
102 //     _8 = const compiler_builtins::int::shift::rust_u128_shro(_1, move _11) -> bb14;
103 //     ...
104 //     _1 = move (_8.0: u128);
105 //     ...
106 //     assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1;
107 //     ...
108 //     assert(!move (_3.1: bool), "attempt to subtract with overflow") -> bb2;
109 //     ...
110 //     assert(!move (_4.1: bool), "attempt to multiply with overflow") -> bb3;
111 //     ...
112 //     assert(!move (_7.1: bool), "attempt to shift left with overflow") -> bb6;
113 //     ...
114 //     _10 = const 6i32 as u128 (Misc);
115 //     _7 = const compiler_builtins::int::shift::rust_u128_shlo(_1, move _10) -> bb12;
116 //     ...
117 //     assert(!move (_8.1: bool), "attempt to shift right with overflow") -> bb7;
118 // END rustc.test_unsigned.Lower128Bit.after.mir