]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/div_overflow.rs
Auto merge of #106458 - albertlarsan68:move-tests, r=jyn514
[rust.git] / tests / mir-opt / div_overflow.rs
1 // compile-flags: -Copt-level=0 -Coverflow-checks=yes
2
3 // Tests that division with a const does not emit a panicking branch for overflow
4
5 // EMIT_MIR div_overflow.const_divisor.PreCodegen.after.mir
6 pub fn const_divisor(a: i32) -> i32 {
7     a / 256
8 }
9
10 // EMIT_MIR div_overflow.const_dividend.PreCodegen.after.mir
11 pub fn const_dividend(a: i32) -> i32 {
12     256 / a
13 }
14
15 fn main() {
16     const_divisor(123);
17     const_dividend(123);
18 }