about summary refs log tree commit diff
path: root/tests/codegen/const-array.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-12-29 00:38:26 +0000
committerbors <bors@rust-lang.org>2024-12-29 00:38:26 +0000
commit0b63477350d8b5d49b86e4f4aedf066b0a5846c0 (patch)
tree45385c4163419fd28ae591cc99dacadfe4a39111 /tests/codegen/const-array.rs
parentb76036c88c1fa7b63f412e777e185336848c52d6 (diff)
parent0a52407d4301e0bd38685058c24f51e287dce22c (diff)
downloadrust-0b63477350d8b5d49b86e4f4aedf066b0a5846c0.tar.gz
rust-0b63477350d8b5d49b86e4f4aedf066b0a5846c0.zip
Auto merge of #134864 - Zalathar:rollup-suc8ay9, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - #134849 (compiletest: Slightly simplify the handling of debugger directive prefixes)
 - #134850 (Document virality of `feature(rustc_private)`)
 - #134852 (Added a codegen test for optimization with const arrays)

r? `@ghost`
`@rustbot` modify labels: rollup
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 }
+}