From 2245ba018801bcd7dee4fba3c7987a30dabfa21f Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Tue, 4 Nov 2025 15:41:40 +0000 Subject: [PATCH 1/2] 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 cc7c363dba01eb..b33edfb7f3a715 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; } /////////////////////////////////////////////////////////////////////////////// From 57f17138c2549fe655684e7aecfbced9c5586d75 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Mon, 15 Dec 2025 11:23:01 +0000 Subject: [PATCH 2/2] Address review comments --- hphp/runtime/vm/jit/vasm-simplify-arm.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hphp/runtime/vm/jit/vasm-simplify-arm.cpp b/hphp/runtime/vm/jit/vasm-simplify-arm.cpp index b33edfb7f3a715..27640659064ede 100644 --- a/hphp/runtime/vm/jit/vasm-simplify-arm.cpp +++ b/hphp/runtime/vm/jit/vasm-simplify-arm.cpp @@ -104,14 +104,18 @@ bool simplify_load_ext(Env& env, const Load& inst, Vlabel b, size_t i) { } bool simplify(Env& env, const loadb& inst, Vlabel b, size_t i) { - if (simplify_load_ext(env, inst, b, i)) + if (simplify_load_ext(env, inst, b, i)) { return true; - if (simplify_load_ext(env, inst, b, i)) + } + if (simplify_load_ext(env, inst, b, i)) { return true; - if (simplify_load_ext(env, inst, b, i)) + } + if (simplify_load_ext(env, inst, b, i)) { return true; - if (simplify_load_ext(env, inst, b, i)) + } + if (simplify_load_ext(env, inst, b, i)) { return true; + } return false; }