Skip to content

Commit

Permalink
Rollup merge of #134852 - alex:patch-1, r=durin42
Browse files Browse the repository at this point in the history
Added a codegen test for optimization with const arrays

Closes #107208
  • Loading branch information
Zalathar authored Dec 28, 2024
2 parents 8060f58 + d6c73eb commit 0a52407
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/codegen/const-array.rs
Original file line number Diff line number Diff line change
@@ -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 }
}

0 comments on commit 0a52407

Please sign in to comment.