about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2025-04-29 17:56:08 +0200
committerptitSeb <sebastien.chev@gmail.com>2025-04-29 17:56:08 +0200
commit737a93a77cd45f69882f51dc3e197b5db6029ebd (patch)
tree150d550edaad256181837b96cf344548c2933c6d /src
parent17cbeab0be9f7919eb37a2e74d131d47ac7a6285 (diff)
downloadbox64-737a93a77cd45f69882f51dc3e197b5db6029ebd.tar.gz
box64-737a93a77cd45f69882f51dc3e197b5db6029ebd.zip
[INTERP] Improved (V)RSQRTSS opcodes
Diffstat (limited to 'src')
-rw-r--r--src/emu/x64runavxf30f.c11
-rw-r--r--src/emu/x64runf30f.c12
2 files changed, 20 insertions, 3 deletions
diff --git a/src/emu/x64runavxf30f.c b/src/emu/x64runavxf30f.c
index 4b2c99de..1e67ecd4 100644
--- a/src/emu/x64runavxf30f.c
+++ b/src/emu/x64runavxf30f.c
@@ -222,7 +222,16 @@ uintptr_t RunAVX_F30F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
             nextop = F8;
             GETEX(0);
             GETGX; GETVX; GETGY;
-            GX->f[0] = 1.0f/sqrtf(EX->f[0]);
+            if(EX->f[0]==0)
+                GX->f[0] = 1.0f/EX->f[0];
+            else if (EX->f[0]<0)
+                GX->f[0] = -NAN;
+            else if (isnan(EX->f[0]))
+                GX->f[0] = EX->f[0];
+            else if (isinf(EX->f[0]))
+                GX->f[0] = 0.0;
+            else
+                GX->f[0] = 1.0f/sqrtf(EX->f[0]);
             if(GX!=VX) {
                 GX->ud[1] = VX->ud[1];
                 GX->q[1] = VX->q[1];
diff --git a/src/emu/x64runf30f.c b/src/emu/x64runf30f.c
index ea31cf01..6ab023ea 100644
--- a/src/emu/x64runf30f.c
+++ b/src/emu/x64runf30f.c
@@ -221,8 +221,16 @@ uintptr_t RunF30F(x64emu_t *emu, rex_t rex, uintptr_t addr)
         nextop = F8;

         GETEX(0);

         GETGX;

-        NAN_PROPAGATION(GX->f[0], EX->f[0], break);

-        GX->f[0] = 1.0f/sqrtf(EX->f[0]);

+        if(EX->f[0]==0)

+            GX->f[0] = 1.0f/EX->f[0];

+        else if (EX->f[0]<0)

+            GX->f[0] = -NAN;

+        else if (isnan(EX->f[0]))

+            GX->f[0] = EX->f[0];

+        else if (isinf(EX->f[0]))

+            GX->f[0] = 0.0;

+        else

+            GX->f[0] = 1.0f/sqrtf(EX->f[0]);

         break;

     case 0x53:  /* RCPSS Gx, Ex */

         nextop = F8;