lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/8] mips: Optimize jit_eqr / jit_eqi


From: Paul Cercueil
Subject: [PATCH v2 1/8] mips: Optimize jit_eqr / jit_eqi
Date: Mon, 9 Jan 2023 23:04:04 +0000

To perform the operation r0 = r1 == 0, the old code would do:
  SLTU(r0, _ZERO_REGNO, r1);
  XORI(r0, r0, 1);

But it is actually possible to do that in a single opcode:
  SLTIU(r0, r1, 1);

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 lib/jit_mips-cpu.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/jit_mips-cpu.c b/lib/jit_mips-cpu.c
index 44fa99d..d73535a 100644
--- a/lib/jit_mips-cpu.c
+++ b/lib/jit_mips-cpu.c
@@ -1948,8 +1948,7 @@ static void
 _eqr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
 {
     subr(r0, r1, r2);
-    SLTU(r0, _ZERO_REGNO, r0);
-    XORI(r0, r0, 1);
+    SLTIU(r0, r0, 1);
 }
 
 static void
@@ -1957,11 +1956,10 @@ _eqi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, 
jit_word_t i0)
 {
     if (i0) {
        subi(r0, r1, i0);
-       SLTU(r0, _ZERO_REGNO, r0);
+       SLTIU(r0, r0, 1);
+    } else {
+       SLTIU(r0, r1, 1);
     }
-    else
-       SLTU(r0, _ZERO_REGNO, r1);
-    XORI(r0, r0, 1);
 }
 
 static void
-- 
2.39.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]