]> git.lizzy.rs Git - rust.git/blob - tests/codegen/issue-73827-bounds-check-index-in-subexpr.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / codegen / issue-73827-bounds-check-index-in-subexpr.rs
1 // This test checks that bounds checks are elided when
2 // index is part of a (x | y) < C style condition
3
4 // compile-flags: -O
5
6 #![crate_type = "lib"]
7
8 // CHECK-LABEL: @get
9 #[no_mangle]
10 pub fn get(array: &[u8; 8], x: usize, y: usize) -> u8 {
11     if x > 7 || y > 7 {
12         0
13     } else {
14         // CHECK-NOT: panic_bounds_check
15         array[y]
16     }
17 }