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
  • Loading branch information
alex authored Dec 28, 2024
1 parent 4e0bc49 commit 95aca05
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/codegen/const-array.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ 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 95aca05

Please sign in to comment.