ZJIT: Remove no-op movs after register allocation

Previously `no_dead_mov_from_vreg` generated:

    0x0: ldur x0, [x0]
    0x4: mov x0, x0
    0x8: ret

Because of phase ordering. Split couldn't recognize that the no-op mov
because at that point it sees a `VReg`.
This commit is contained in:
Alan Wu 2025-07-18 15:31:07 -04:00
parent 495e3f642b
commit 3bbdcf0848
2 changed files with 17 additions and 0 deletions

View File

@ -1424,6 +1424,20 @@ mod tests {
");
}
#[test]
fn no_dead_mov_from_vreg() {
let (mut asm, mut cb) = setup_asm();
let ret_val = asm.load(Opnd::mem(64, C_RET_OPND, 0));
asm.cret(ret_val);
asm.compile_with_num_regs(&mut cb, 1);
assert_disasm!(cb, "000040f8c0035fd6", "
0x0: ldur x0, [x0]
0x4: ret
");
}
#[test]
fn test_emit_add() {
let (mut asm, mut cb) = setup_asm();

View File

@ -1752,6 +1752,9 @@ impl Assembler
asm.push_insn(Insn::PosMarker(end_marker));
}
}
Insn::Mov { src, dest } | Insn::LoadInto { dest, opnd: src } if src == dest => {
// Remove no-op move now that VReg are resolved to physical Reg
}
_ => asm.push_insn(insn),
}