Skip to content

Commit

Permalink
Added a codegen test for optimization with const arrays
Browse files Browse the repository at this point in the history
Closes #107208
  • Loading branch information
alex committed Dec 28, 2024
1 parent ceb0441 commit d6c73eb
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 d6c73eb

Please sign in to comment.