diff --git a/tests/codegen/const-array.rs b/tests/codegen/const-array.rs new file mode 100644 index 0000000000000..f23079627351c --- /dev/null +++ b/tests/codegen/const-array.rs @@ -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 + } +}