1
Fork 0

Avoid wrapping constant allocations in packed structs when not necessary

This way LLVM will set the string merging flag if the alloc is a nul
terminated string, reducing binary sizes.
This commit is contained in:
bjorn3 2025-03-14 15:56:33 +00:00
parent f7b4354283
commit a5fa12b6b9
8 changed files with 26 additions and 25 deletions

View file

@ -2,7 +2,7 @@
#![crate_type = "lib"]
const LUT: [u8; 2] = [1, 1];
const LUT: [u8; 4] = [1, 1, 1, 1];
// CHECK-LABEL: @decode
#[no_mangle]
@ -11,5 +11,5 @@ pub fn decode(i: u8) -> u8 {
// CHECK-NEXT: icmp
// CHECK-NEXT: select
// CHECK-NEXT: ret
if i < 2 { LUT[i as usize] } else { 2 }
if i < 4 { LUT[i as usize] } else { 2 }
}