]> git.lizzy.rs Git - rust.git/commitdiff
Add codegen test for issue #73827
authorDániel Buga <bugadani@gmail.com>
Sat, 17 Oct 2020 11:17:31 +0000 (13:17 +0200)
committerDániel Buga <bugadani@gmail.com>
Sat, 17 Oct 2020 11:18:29 +0000 (13:18 +0200)
src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs [new file with mode: 0644]

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 (file)
index 0000000..d07eaa7
--- /dev/null
@@ -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]
+    }
+}