We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ba63a84 + 10a4c67 commit a315442Copy full SHA for a315442
src/test/codegen/issue-75525-bounds-checks.rs
@@ -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
17
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
24
25
+pub fn f2(idx: usize, buf: &[u8; 10]) -> u8 {
26
+ if idx > 5 && idx < 8 { buf[idx] } else { 0 }
27
0 commit comments