From 0473edbcd6b781d457215b07871fcb8436c74125 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Tue, 4 Nov 2025 14:34:21 +0000 Subject: [PATCH] Use 3 mov instructions to implement register swaps According to the software optimisation guide mov instructions between GPRs may be zero latency, which is even cheaper than using 3 eors. --- hphp/runtime/vm/jit/vasm-arm.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hphp/runtime/vm/jit/vasm-arm.cpp b/hphp/runtime/vm/jit/vasm-arm.cpp index e972222e9abfc..b1d48c0544771 100644 --- a/hphp/runtime/vm/jit/vasm-arm.cpp +++ b/hphp/runtime/vm/jit/vasm-arm.cpp @@ -758,9 +758,11 @@ void Vgen::emit(const copy2& i) { assertx(d0 != d1); if (d0 == s1) { if (d1 == s0) { - a->Eor(X(d0), X(d0), X(s0)); - a->Eor(X(s0), X(d0), X(s0)); - a->Eor(X(d0), X(d0), X(s0)); + a->SetScratchRegisters(vixl::NoReg, vixl::NoReg); + a->Mov(rVixlScratch0, X(d0)); + a->Mov(X(d0), X(s0)); + a->Mov(X(s0), rVixlScratch0); + a->SetScratchRegisters(rVixlScratch0, rVixlScratch1); } else { // could do this in a simplify pass if (s1 != d1) a->Mov(X(s1), X(d1)); // save s1 first; d1 != s0