Skip to content

Commit 3bbdcf0

Browse files
committed
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`.
1 parent 495e3f6 commit 3bbdcf0

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

zjit/src/backend/arm64/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,20 @@ mod tests {
14241424
");
14251425
}
14261426

1427+
#[test]
1428+
fn no_dead_mov_from_vreg() {
1429+
let (mut asm, mut cb) = setup_asm();
1430+
1431+
let ret_val = asm.load(Opnd::mem(64, C_RET_OPND, 0));
1432+
asm.cret(ret_val);
1433+
1434+
asm.compile_with_num_regs(&mut cb, 1);
1435+
assert_disasm!(cb, "000040f8c0035fd6", "
1436+
0x0: ldur x0, [x0]
1437+
0x4: ret
1438+
");
1439+
}
1440+
14271441
#[test]
14281442
fn test_emit_add() {
14291443
let (mut asm, mut cb) = setup_asm();

zjit/src/backend/lir.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,9 @@ impl Assembler
17521752
asm.push_insn(Insn::PosMarker(end_marker));
17531753
}
17541754
}
1755+
Insn::Mov { src, dest } | Insn::LoadInto { dest, opnd: src } if src == dest => {
1756+
// Remove no-op move now that VReg are resolved to physical Reg
1757+
}
17551758
_ => asm.push_insn(insn),
17561759
}
17571760

0 commit comments

Comments
 (0)