about summary refs log tree commit diff
path: root/tests/codegen/const-array.rs
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2024-12-31 05:12:50 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2024-12-31 05:12:50 +0000
commite898da11d2149358e87f7c4f89dcc0654fcfac3b (patch)
tree6f09bd54aead12fa9e0155cda3dcb7e0f46f97ae /tests/codegen/const-array.rs
parent332fefbd3e686d0d76a43119e374997543338389 (diff)
parent5079acc060b1c7225de95ee3cdd84b5719ff189c (diff)
downloadrust-e898da11d2149358e87f7c4f89dcc0654fcfac3b.tar.gz
rust-e898da11d2149358e87f7c4f89dcc0654fcfac3b.zip
Merge from rustc
Diffstat (limited to 'tests/codegen/const-array.rs')
-rw-r--r--tests/codegen/const-array.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/codegen/const-array.rs b/tests/codegen/const-array.rs
new file mode 100644
index 00000000000..f2b331c315d
--- /dev/null
+++ b/tests/codegen/const-array.rs
@@ -0,0 +1,15 @@
+//@ compile-flags: -O
+
+#![crate_type = "lib"]
+
+const LUT: [u8; 2] = [1, 1];
+
+// CHECK-LABEL: @decode
+#[no_mangle]
+pub fn decode(i: u8) -> u8 {
+    // CHECK: start:
+    // CHECK-NEXT: icmp
+    // CHECK-NEXT: select
+    // CHECK-NEXT: ret
+    if i < 2 { LUT[i as usize] } else { 2 }
+}