From 2245ba018801bcd7dee4fba3c7987a30dabfa21f Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Tue, 4 Nov 2025 15:41:40 +0000 Subject: [PATCH] AArch64: Add support for more extending loads Support more simplifications combining loadb with various zero- and sign-extending moves. --- hphp/runtime/vm/jit/vasm-simplify-arm.cpp | 34 ++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/hphp/runtime/vm/jit/vasm-simplify-arm.cpp b/hphp/runtime/vm/jit/vasm-simplify-arm.cpp index cc7c363dba01e..b33edfb7f3a71 100644 --- a/hphp/runtime/vm/jit/vasm-simplify-arm.cpp +++ b/hphp/runtime/vm/jit/vasm-simplify-arm.cpp @@ -91,26 +91,28 @@ bool simplify(Env& env, const cmovq& inst, Vlabel b, size_t i) { /////////////////////////////////////////////////////////////////////////////// -bool simplify(Env& env, const loadb& inst, Vlabel b, size_t i) { - if (if_inst(env, b, i + 1, [&] (const movzbl& mov) { - // loadb{s, tmp}; movzbl{tmp, d}; -> loadzbl{s, d}; - if (!(env.use_counts[inst.d] == 1 && inst.d == mov.s)) return false; +template +bool simplify_load_ext(Env& env, const Load& inst, Vlabel b, size_t i) { + return if_inst(env, b, i + 1, [&] (const ExtMov& mov) { + if (env.use_counts[inst.d] != 1 || inst.d != mov.s) return false; return simplify_impl(env, b, i, [&] (Vout& v) { - v << loadzbl{inst.s, mov.d}; + v << ExtLoad{inst.s, mov.d}; return 2; - }); })) { - return true; - } - - return if_inst(env, b, i + 1, [&] (const movsbl& mov) { - // loadb{s, tmp}; movsbl{tmp, d}; -> loadsbl{s, d}; - if (!(env.use_counts[inst.d] == 1 && inst.d == mov.s)) return false; + }); + }); +} - return simplify_impl(env, b, i, [&] (Vout& v) { - v << loadsbl{inst.s, mov.d}; - return 2; - }); }); +bool simplify(Env& env, const loadb& inst, Vlabel b, size_t i) { + if (simplify_load_ext(env, inst, b, i)) + return true; + if (simplify_load_ext(env, inst, b, i)) + return true; + if (simplify_load_ext(env, inst, b, i)) + return true; + if (simplify_load_ext(env, inst, b, i)) + return true; + return false; } ///////////////////////////////////////////////////////////////////////////////