File 1142-AArch64-Reduce-the-number-of-instructions-for-i_leng.patch of Package erlang

From a9acd3ef7b10874e38c6068285a81939e11d0945 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 29 Sep 2023 06:58:12 +0200
Subject: [PATCH 22/25] AArch64: Reduce the number of instructions for
 i_length_setup

---
 erts/emulator/beam/jit/arm/instr_bif.cpp | 27 ++++++++++++++++--------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/erts/emulator/beam/jit/arm/instr_bif.cpp b/erts/emulator/beam/jit/arm/instr_bif.cpp
index ca6db3e6e8..9cf133bcc7 100644
--- a/erts/emulator/beam/jit/arm/instr_bif.cpp
+++ b/erts/emulator/beam/jit/arm/instr_bif.cpp
@@ -196,20 +196,29 @@ void BeamModuleAssembler::emit_nofail_bif2(const ArgSource &Src1,
 void BeamModuleAssembler::emit_i_length_setup(const ArgLabel &Fail,
                                               const ArgWord &Live,
                                               const ArgSource &Src) {
-    mov_arg(TMP1, Src);
-    mov_imm(TMP2, make_small(0));
-
     /* Store trap state after the currently live registers. There are
      * 3 extra registers beyond the ordinary ones that we're free to
      * use for whatever purpose. */
     ERTS_CT_ASSERT(ERTS_X_REGS_ALLOCATED - MAX_REG >= 3);
-    mov_arg(ArgXRegister(Live.get() + 0), TMP1);
-    mov_arg(ArgXRegister(Live.get() + 1), TMP2);
+    auto trap_reg1 = ArgXRegister(Live.get() + 0);
+    auto trap_reg2 = ArgXRegister(Live.get() + 1);
+    auto trap_reg3 = ArgXRegister(Live.get() + 2);
+
+    auto src = load_source(Src, TMP1);
+    auto dst1 = init_destination(trap_reg1, src.reg);
+    auto dst2 = init_destination(trap_reg2, TMP2);
+
+    mov_imm(dst2.reg, make_small(0));
+    mov_var(dst1, src);
 
-    /* Store original argument. This is only needed for exceptions and can be
-     * safely skipped in guards. */
-    if (Fail.get() == 0) {
-        mov_arg(ArgXRegister(Live.get() + 2), TMP1);
+    /* Store original argument. This is only needed for exceptions and
+     * can be safely skipped in guards. */
+    if (Fail.get() != 0) {
+        flush_vars(dst1, dst2);
+    } else {
+        auto dst3 = init_destination(trap_reg3, src.reg);
+        mov_var(dst3, src);
+        flush_vars(dst1, dst2, dst3);
     }
 }
 
-- 
2.35.3

openSUSE Build Service is sponsored by