Skip to content

Commit 0a52407

Browse files
authored
Rollup merge of #134852 - alex:patch-1, r=durin42
Added a codegen test for optimization with const arrays Closes #107208
2 parents 8060f58 + d6c73eb commit 0a52407

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/codegen/const-array.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -O
2+
3+
#![crate_type = "lib"]
4+
5+
const LUT: [u8; 2] = [1, 1];
6+
7+
// CHECK-LABEL: @decode
8+
#[no_mangle]
9+
pub fn decode(i: u8) -> u8 {
10+
// CHECK: start:
11+
// CHECK-NEXT: icmp
12+
// CHECK-NEXT: select
13+
// CHECK-NEXT: ret
14+
if i < 2 { LUT[i as usize] } else { 2 }
15+
}

0 commit comments

Comments
 (0)