about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs')
-rw-r--r--tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs b/tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs
new file mode 100644
index 00000000000..ecb5eb787c7
--- /dev/null
+++ b/tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs
@@ -0,0 +1,13 @@
+// Tests that no bounds check panic is generated for `j` since
+// `j <= i < data.len()`.
+
+//@ compile-flags: -Copt-level=3
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @issue_80075
+#[no_mangle]
+pub fn issue_80075(data: &[u8], i: usize, j: usize) -> u8 {
+    // CHECK-NOT: panic_bounds_check
+    if i < data.len() && j <= i { data[j] } else { 0 }
+}