Skip to main content

peephole_eliminate_dead_load_imm

Function peephole_eliminate_dead_load_imm 

Source
pub fn peephole_eliminate_dead_load_imm(
    code: &mut [u8],
    bitmask: &mut [u8],
    jump_table: &[u32],
) -> usize
Expand description

Peephole pass: eliminate dead load_imm instructions.

When a load_imm (opcode 51) or load_imm_64 (opcode 20) writes to register R, and the immediately following instruction also writes to R without reading it (another load_imm/load_imm_64, or move_reg with R as destination), the first instruction is dead and can be replaced with a no-op (bitmask cleared).

The second instruction must not be a branch target (otherwise the first load_imm could be reached independently via a different path).