1
Fork 0

Added a codegen test for optimization with const arrays

Closes #107208
This commit is contained in:
Alex Gaynor 2024-12-28 10:14:46 -05:00
parent ceb0441e82
commit d6c73ebbf3

View file

@ -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 }
}