[INTERP] Improved NAN handling for some (V)SQRTS[S/D] opcodes

This commit is contained in:
ptitSeb 2025-04-30 15:46:08 +02:00
parent ab70523b39
commit 7b2e084170
4 changed files with 12 additions and 2 deletions

View File

@ -188,6 +188,8 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETGX; GETVX; GETGY;
if(EX->d[0]<0.0 )
GX->d[0] = -NAN;
else if(isnan(EX->d[0]))
GX->d[0] = EX->d[0];
else
GX->d[0] = sqrt(EX->d[0]);
GX->q[1] = VX->q[1];

View File

@ -210,6 +210,8 @@ uintptr_t RunAVX_F30F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETGX; GETVX; GETGY;
if(EX->f[0]<0.0 )
GX->f[0] = -NAN;
else if(isnanf(EX->f[0]))
GX->f[0] = EX->f[0];
else
GX->f[0] = sqrt(EX->f[0]);
if(GX!=VX) {

View File

@ -209,6 +209,8 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
GETGX;
if(EX->d[0]<0.0 )
GX->d[0] = -NAN;
else if(isnan(EX->d[0]))
GX->d[0] = EX->d[0];
else
GX->d[0] = sqrt(EX->d[0]);
break;

View File

@ -214,8 +214,12 @@ 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] = sqrtf(EX->f[0]);
if (EX->f[0]<0)
GX->f[0] = -NAN;
else if (isnanf(EX->f[0]))
GX->f[0] = EX->f[0];
else
GX->f[0] = sqrtf(EX->f[0]);
break;
case 0x52: /* RSQRTSS Gx, Ex */
nextop = F8;