about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDániel Buga <bugadani@gmail.com>2020-10-17 13:17:31 +0200
committerDániel Buga <bugadani@gmail.com>2020-10-17 13:18:29 +0200
commit64c239cbd6d694dbe2a5a13198c265669d7a8f8e (patch)
tree70fc2ba5712ab2bba70f75fe700174621bd62ad2 /src
parent8850893d96252172700727fe9e746c8e1ebd5853 (diff)
downloadrust-64c239cbd6d694dbe2a5a13198c265669d7a8f8e.tar.gz
rust-64c239cbd6d694dbe2a5a13198c265669d7a8f8e.zip
Add codegen test for issue #73827
Diffstat (limited to 'src')
-rw-r--r--src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs b/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs
new file mode 100644
index 00000000000..d07eaa75b7a
--- /dev/null
+++ b/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs
@@ -0,0 +1,18 @@
+// This test checks that bounds checks are elided when
+// index is part of a (x | y) < C style condition
+
+// min-llvm-version: 11.0.0
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @get
+#[no_mangle]
+pub fn get(array: &[u8; 8], x: usize, y: usize) -> u8 {
+    if x > 7 || y > 7 {
+        0
+    } else {
+        // CHECK-NOT: panic_bounds_check
+        array[y]
+    }
+}