mips: Optimize jit_lei / jit_lei_u - lightning.git - Portable just-in-time compiler library

index : lightning.git
Portable just-in-time compiler library
summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorPaul Cercueil <paul@crapouillou.net>2022年05月19日 10:39:16 +0100
committerpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2022年05月19日 10:04:04 -0300
commit1e448af913f150c784dc724faca32d3c23303147 (patch)
tree6125a032dc3f42097ebcb3d776e0b344556f7192 /lib
parentf579802f4f1533cd9b3de77b8b298ed1a109f5cf (diff)
downloadlightning-1e448af913f150c784dc724faca32d3c23303147.tar.gz
mips: Optimize jit_lei / jit_lei_u
When working with integers, expressing (reg <= i0) is equivalent to (reg < i0 + 1). If (i0 + 1) can fit in a 16-bit signed word, it is then possible to implement jit_lei() with just one SLTI opcode and jit_lei_u() with just one SLTIU opcode, respectively. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/jit_mips-cpu.c 12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/jit_mips-cpu.c b/lib/jit_mips-cpu.c
index 35fb9f6..27ef5f7 100644
--- a/lib/jit_mips-cpu.c
+++ b/lib/jit_mips-cpu.c
@@ -1897,10 +1897,8 @@ _lei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
jit_int32_t reg;
- if (i0 == 0) {
- SLT(r0, _ZERO_REGNO, r1);
- XORI(r0, r0, 1);
- }
+ if (can_sign_extend_short_p(i0 + 1))
+ SLTI(r0, r1, i0 + 1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
@@ -1921,10 +1919,8 @@ _lei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
jit_int32_t reg;
- if (i0 == 0) {
- SLTU(r0, _ZERO_REGNO, r1);
- XORI(r0, r0, 1);
- }
+ if (can_sign_extend_short_p(i0 + 1))
+ SLTIU(r0, r1, i0 + 1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月28日 08:19:03 +0000

AltStyle によって変換されたページ (->オリジナル) /