File 2167-Use-shorter-test-instructions.patch of Package erlang
From 78b4d1de09626f23f580a3c4f2b80b9def74ef83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Sat, 10 Sep 2022 07:35:35 +0200
Subject: [PATCH 7/7] Use shorter test instructions
The TEST instruction with byte-size operands is shorter than
the TEST instruction with four-byte operands.
---
erts/emulator/beam/jit/x86/instr_bs.cpp | 2 +-
erts/emulator/beam/jit/x86/instr_fun.cpp | 2 +-
erts/emulator/beam/jit/x86/instr_map.cpp | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/erts/emulator/beam/jit/x86/instr_bs.cpp b/erts/emulator/beam/jit/x86/instr_bs.cpp
index 9e2a40439c..b59e305298 100644
--- a/erts/emulator/beam/jit/x86/instr_bs.cpp
+++ b/erts/emulator/beam/jit/x86/instr_bs.cpp
@@ -1914,7 +1914,7 @@ void BeamModuleAssembler::emit_i_bs_create_bin(const ArgLabel &Fail,
} else if (always_one_of(seg.size,
BEAM_TYPE_FLOAT | BEAM_TYPE_INTEGER)) {
comment("simplified test for small size since it is a number");
- a.test(ARG1d, imm(TAG_PRIMARY_LIST));
+ a.test(ARG1.r8(), imm(TAG_PRIMARY_LIST));
a.je(error);
} else {
a.mov(RETd, ARG1d);
diff --git a/erts/emulator/beam/jit/x86/instr_fun.cpp b/erts/emulator/beam/jit/x86/instr_fun.cpp
index 1ae19aaaba..f51c81f4c9 100644
--- a/erts/emulator/beam/jit/x86/instr_fun.cpp
+++ b/erts/emulator/beam/jit/x86/instr_fun.cpp
@@ -242,7 +242,7 @@ void BeamGlobalAssembler::emit_apply_fun_shared() {
a.cmp(ARG1d, imm(NIL));
a.short_().je(finished);
- a.test(ARG1d, imm(_TAG_PRIMARY_MASK - TAG_PRIMARY_LIST));
+ a.test(ARG1.r8(), imm(_TAG_PRIMARY_MASK - TAG_PRIMARY_LIST));
a.short_().jne(malformed_list);
emit_ptr_val(ARG1, ARG1);
diff --git a/erts/emulator/beam/jit/x86/instr_map.cpp b/erts/emulator/beam/jit/x86/instr_map.cpp
index 94f13e3e0c..9a94e37118 100644
--- a/erts/emulator/beam/jit/x86/instr_map.cpp
+++ b/erts/emulator/beam/jit/x86/instr_map.cpp
@@ -148,7 +148,7 @@ void BeamGlobalAssembler::emit_hashmap_get_element() {
emit_ptr_val(node, node);
/* Have we found our leaf? */
- a.test(node.r32(), imm(_TAG_PRIMARY_MASK - TAG_PRIMARY_LIST));
+ a.test(node.r8(), imm(_TAG_PRIMARY_MASK - TAG_PRIMARY_LIST));
a.short_().je(leaf_node);
/* Nope, we have to search another node. */
--
2.35.3