From 75baceba66de295f366ef0aed365e20f7d06adc8 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Wed, 5 Nov 2025 13:56:22 +0000 Subject: [PATCH] AArch64: Fold movtqb + movzbq into just a movzbq --- hphp/runtime/vm/jit/vasm-simplify-arm.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hphp/runtime/vm/jit/vasm-simplify-arm.cpp b/hphp/runtime/vm/jit/vasm-simplify-arm.cpp index cc7c363dba01e..e2b8df38409a9 100644 --- a/hphp/runtime/vm/jit/vasm-simplify-arm.cpp +++ b/hphp/runtime/vm/jit/vasm-simplify-arm.cpp @@ -134,6 +134,23 @@ bool simplify(Env& env, const ldimmq& inst, Vlabel b, size_t i) { /////////////////////////////////////////////////////////////////////////////// +bool simplify(Env& env, const movtqb& inst, Vlabel b, size_t i) { + if (env.use_counts[inst.d] != 1) + return false; + + if (if_inst(env, b, i + 1, [&](const movzbq& ext) { + if (ext.s != inst.d) + return false; + + return simplify_impl(env, b, i, [&] (Vout& v) { + v << movzbq{Vreg8((Vreg)inst.s), ext.d}; + return 2; + }); + })) { + } + return false; +} + bool simplify(Env& env, const movzbl& inst, Vlabel b, size_t i) { // movzbl{s, d}; shrli{2, s, d} --> ubfmli{2, 7, s, d} return if_inst(env, b, i + 1, [&](const shrli& sh) {