Skip to main content

optimize_instruction

Function optimize_instruction 

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

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

Returns true if the instruction was modified.

§Side effects

The zero-idiom transform (mov reg, 0xor reg, reg) clobbers FLAGS (sets ZF=1, clears CF/PF/SF/OF). This matches the behaviour of GAS and NASM at -O2 and is safe whenever FLAGS are dead after the instruction, which is the common case in practice.