]> git.proxmox.com Git - rustc.git/blame - src/test/codegen/issue-75525-bounds-checks.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / codegen / issue-75525-bounds-checks.rs
CommitLineData
6a06907d
XL
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]
11pub 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]
18pub 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]
25pub fn f2(idx: usize, buf: &[u8; 10]) -> u8 {
26 if idx > 5 && idx < 8 { buf[idx] } else { 0 }
27}