about summary refs log tree commit diff
path: root/tests/codegen/const-array.rs
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@users.noreply.github.com>2025-01-07 16:13:25 +0000
committerGitHub <noreply@github.com>2025-01-07 16:13:25 +0000
commitfd1e95538fa3b3ca87fc4f7df5e9abd918949536 (patch)
treef2f3317a4a2031c7cc1a141c5703166e6fa1d107 /tests/codegen/const-array.rs
parent8e4409cce3e4a7f7eb974462c943e717db818ed8 (diff)
parente103ab16084dc735b8db6b90186cd7b6967402ee (diff)
downloadrust-fd1e95538fa3b3ca87fc4f7df5e9abd918949536.tar.gz
rust-fd1e95538fa3b3ca87fc4f7df5e9abd918949536.zip
Merge pull request #18874 from lnicola/sync-from-rust
minor: Sync from downstream
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 }
+}