Skip to main content

optimize_instruction

Function optimize_instruction 

Source
pub fn optimize_instruction(
    instr: &mut Instruction,
    arch: Arch,
    level: OptLevel,
) -> bool
Expand description

Apply peephole optimizations to an instruction (mutates in place).

Returns true if the instruction was modified.

At OptLevel::Size every transform is observationally equivalent — the rewritten instruction leaves registers, memory and FLAGS exactly as the original would, so an assembler user never has to reason about whether optimization was on. Transforms that clobber FLAGS are gated behind OptLevel::Aggressive.