about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-02-13 23:58:15 +0800
committerGitHub <noreply@github.com>2025-02-13 16:58:15 +0100
commit05fd25d3bbdf3d7b21f795785658899c7b8063b6 (patch)
tree697d28ed7e8070415fb2e5c721b12f77c2dc4bf4 /src
parent2b75a0de556dc67dc0ed3c91fa90b5ffd4d40507 (diff)
downloadbox64-05fd25d3bbdf3d7b21f795785658899c7b8063b6.tar.gz
box64-05fd25d3bbdf3d7b21f795785658899c7b8063b6.zip
[RV64_DYNAREC] Minor optimization to CMOV opcodes (#2354)
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/rv64/dynarec_rv64_0f.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c
index 35441901..fdc8eb0b 100644
--- a/src/dynarec/rv64/dynarec_rv64_0f.c
+++ b/src/dynarec/rv64/dynarec_rv64_0f.c
@@ -938,11 +938,22 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
     if (MODREG) {                                                                                \
         ed = TO_NAT((nextop & 7) + (rex.b << 3));                                                \
         if (dyn->insts[ninst].nat_flags_fusion) {                                                \
-            NATIVEJUMP(NATNO, 8);                                                                \
+            NATIVEJUMP(NATNO, (rex.w || rv64_xtheadbb || rv64_zba) ? 8 : 12);                    \
         } else {                                                                                 \
-            B##NO(tmp1, 8);                                                                      \
+            B##NO(tmp1, (rex.w || rv64_xtheadbb || rv64_zba) ? 8 : 12);                          \
+        }                                                                                        \
+        if (rex.w)                                                                               \
+            MV(gd, ed);                                                                          \
+        else {                                                                                   \
+            if (rv64_zba) {                                                                      \
+                ZEXTW(gd, ed);                                                                   \
+            } else if (rv64_xtheadbb) {                                                          \
+                TH_EXTU(gd, ed, 31, 0);                                                          \
+            } else {                                                                             \
+                SLLI(gd, ed, 32);                                                                \
+                SRLI(gd, gd, 32);                                                                \
+            }                                                                                    \
         }                                                                                        \
-        MV(gd, ed);                                                                              \
     } else {                                                                                     \
         addr = geted(dyn, addr, ninst, nextop, &ed, tmp2, tmp3, &fixedaddress, rex, NULL, 1, 0); \
         if (dyn->insts[ninst].nat_flags_fusion) {                                                \
@@ -951,8 +962,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
             B##NO(tmp1, 8);                                                                      \
         }                                                                                        \
         LDxw(gd, ed, fixedaddress);                                                              \
-    }                                                                                            \
-    if (!rex.w) ZEROUP(gd);
+    }
 
             GOCOND(0x40, "CMOV", "Gd, Ed");
 #undef GO