]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/issue-75525-bounds-checks.rs
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
[rust.git] / src / test / codegen / issue-75525-bounds-checks.rs
1 // Regression test for #75525, verifies that no bounds checks are generated.
2
3 // min-llvm-version: 12.0.0
4 // compile-flags: -O
5
6 #![crate_type = "lib"]
7
8 // CHECK-LABEL: @f0
9 // CHECK-NOT: panic
10 #[no_mangle]
11 pub fn f0(idx: usize, buf: &[u8; 10]) -> u8 {
12     if idx < 8 { buf[idx + 1] } else { 0 }
13 }
14
15 // CHECK-LABEL: @f1
16 // CHECK-NOT: panic
17 #[no_mangle]
18 pub fn f1(idx: usize, buf: &[u8; 10]) -> u8 {
19     if idx > 5 && idx < 8 { buf[idx - 1] } else { 0 }
20 }
21
22 // CHECK-LABEL: @f2
23 // CHECK-NOT: panic
24 #[no_mangle]
25 pub fn f2(idx: usize, buf: &[u8; 10]) -> u8 {
26     if idx > 5 && idx < 8 { buf[idx] } else { 0 }
27 }