about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/elided-division-by-zero-check-74917.rs
blob: 9e890e148527a5f1f83de004ad004671d87ea28a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Tests that there is no check for dividing by zero since the
// denominator, `(x - y)`, will always be greater than 0 since `x > y`.

//@ compile-flags: -Copt-level=3

#![crate_type = "lib"]

// CHECK-LABEL: @issue_74917
#[no_mangle]
pub fn issue_74917(x: u16, y: u16) -> u16 {
    // CHECK-NOT: panic
    if x > y { 100 / (x - y) } else { 100 }
}