[INTERP] Fixed overflow checking for convertion opcodes (#1976)

This commit is contained in:
Yang Liu 2024-10-29 21:11:13 +08:00 committed by GitHub
parent 2aff4239cc
commit 8807b1aa3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 20 deletions

View File

@ -2389,11 +2389,11 @@ uintptr_t Run660F(x64emu_t *emu, rex_t rex, uintptr_t addr)
nextop = F8;
GETEX(0);
GETGX;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GX->sd[0] = 0x80000000;
else
GX->sd[0] = EX->d[0];
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>0x7fffffff)
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>(double)0x7fffffff)
GX->sd[1] = 0x80000000;
else
GX->sd[1] = EX->d[1];

View File

@ -1714,21 +1714,21 @@ uintptr_t RunAVX_660F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGX;
GETGY;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GX->sd[0] = 0x80000000;
else
GX->sd[0] = EX->d[0];
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>0x7fffffff)
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>(double)0x7fffffff)
GX->sd[1] = 0x80000000;
else
GX->sd[1] = EX->d[1];
if(vex.l) {
GETEY;
if(isnan(EY->d[0]) || isinf(EY->d[0]) || EY->d[0]>0x7fffffff)
if(isnan(EY->d[0]) || isinf(EY->d[0]) || EY->d[0]>(double)0x7fffffff)
GX->sd[2] = 0x80000000;
else
GX->sd[2] = EY->d[0];
if(isnan(EY->d[1]) || isinf(EY->d[1]) || EY->d[1]>0x7fffffff)
if(isnan(EY->d[1]) || isinf(EY->d[1]) || EY->d[1]>(double)0x7fffffff)
GX->sd[3] = 0x80000000;
else
GX->sd[3] = EY->d[1];

View File

@ -119,12 +119,12 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if(rex.w)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->d[0];
else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->d[0];
@ -136,7 +136,7 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if(rex.w) {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {
@ -158,7 +158,7 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
break;
}
} else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {

View File

@ -142,12 +142,12 @@ uintptr_t RunAVX_F30F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if (rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->f[0];
} else {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffff)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->f[0];
@ -159,7 +159,7 @@ uintptr_t RunAVX_F30F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if(rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {

View File

@ -93,12 +93,12 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
_GETEX(0);
GETGD;
if(rex.w)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->d[0];
else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->d[0];
@ -110,7 +110,7 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
_GETEX(0);
GETGD;
if(rex.w) {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {
@ -132,7 +132,7 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
break;
}
} else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {

View File

@ -104,12 +104,12 @@ uintptr_t RunF30F(x64emu_t *emu, rex_t rex, uintptr_t addr)
GETEX(0);
GETGD;
if (rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->f[0];
} else {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffff)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->f[0];
@ -121,7 +121,7 @@ uintptr_t RunF30F(x64emu_t *emu, rex_t rex, uintptr_t addr)
GETEX(0);
GETGD;
if(rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {