Skip to content

Commit a315442

Browse files
authored
Rollup merge of rust-lang#82799 - bugadani:codegen-tests, r=nagisa
Add regression test for rust-lang#75525
2 parents ba63a84 + 10a4c67 commit a315442

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)