Merge pull request #3408 from Tilka/fcmp

JitArm64: fix fcmpo/fcmpu
This commit is contained in:
Ryan Houdek 2016-01-04 22:19:32 -05:00
commit e8e0ad3e52
10 changed files with 19 additions and 43 deletions

View File

@ -24,7 +24,6 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction _inst, double fa,
if (std::isnan(fa) || std::isnan(fb)) if (std::isnan(fa) || std::isnan(fb))
{ {
FPSCR.FX = 1;
compareResult = FPCC::FU; compareResult = FPCC::FU;
if (IsSNAN(fa) || IsSNAN(fb)) if (IsSNAN(fa) || IsSNAN(fb))
{ {
@ -68,7 +67,6 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double f
if (IsSNAN(fa) || IsSNAN(fb)) if (IsSNAN(fa) || IsSNAN(fb))
{ {
FPSCR.FX = 1;
SetFPException(FPSCR_VXSNAN); SetFPException(FPSCR_VXSNAN);
} }
} }

View File

@ -214,7 +214,7 @@ public:
void fp_arith(UGeckoInstruction inst); void fp_arith(UGeckoInstruction inst);
void fcmpx(UGeckoInstruction inst); void fcmpX(UGeckoInstruction inst);
void fctiwx(UGeckoInstruction inst); void fctiwx(UGeckoInstruction inst);
void fmrx(UGeckoInstruction inst); void fmrx(UGeckoInstruction inst);
void frspx(UGeckoInstruction inst); void frspx(UGeckoInstruction inst);

View File

@ -322,8 +322,8 @@ static GekkoOPTemplate table59[] =
static GekkoOPTemplate table63[] = static GekkoOPTemplate table63[] =
{ {
{264, &Jit64::fsign}, // fabsx {264, &Jit64::fsign}, // fabsx
{32, &Jit64::fcmpx}, // fcmpo {32, &Jit64::fcmpX}, // fcmpo
{0, &Jit64::fcmpx}, // fcmpu {0, &Jit64::fcmpX}, // fcmpu
{14, &Jit64::fctiwx}, // fctiwx {14, &Jit64::fctiwx}, // fctiwx
{15, &Jit64::fctiwx}, // fctiwzx {15, &Jit64::fctiwx}, // fctiwzx
{72, &Jit64::fmrx}, // fmrx {72, &Jit64::fmrx}, // fmrx

View File

@ -556,7 +556,7 @@ void Jit64::FloatCompare(UGeckoInstruction inst, bool upper)
fpr.UnlockAll(); fpr.UnlockAll();
} }
void Jit64::fcmpx(UGeckoInstruction inst) void Jit64::fcmpX(UGeckoInstruction inst)
{ {
INSTRUCTION_START INSTRUCTION_START
JITDISABLE(bJITFloatingPointOff); JITDISABLE(bJITFloatingPointOff);

View File

@ -323,8 +323,8 @@ static GekkoOPTemplate table59[] =
static GekkoOPTemplate table63[] = static GekkoOPTemplate table63[] =
{ {
{264, &JitIL::fsign}, //"fabsx", OPTYPE_FPU, FL_RC_BIT_F}}, {264, &JitIL::fsign}, //"fabsx", OPTYPE_FPU, FL_RC_BIT_F}},
{32, &JitIL::fcmpx}, //"fcmpo", OPTYPE_FPU, FL_RC_BIT_F}}, {32, &JitIL::fcmpX}, //"fcmpo", OPTYPE_FPU, FL_RC_BIT_F}},
{0, &JitIL::fcmpx}, //"fcmpu", OPTYPE_FPU, FL_RC_BIT_F}}, {0, &JitIL::fcmpX}, //"fcmpu", OPTYPE_FPU, FL_RC_BIT_F}},
{14, &JitIL::FallBackToInterpreter}, //"fctiwx", OPTYPE_FPU, FL_RC_BIT_F}}, {14, &JitIL::FallBackToInterpreter}, //"fctiwx", OPTYPE_FPU, FL_RC_BIT_F}},
{15, &JitIL::FallBackToInterpreter}, //"fctiwzx", OPTYPE_FPU, FL_RC_BIT_F}}, {15, &JitIL::FallBackToInterpreter}, //"fctiwzx", OPTYPE_FPU, FL_RC_BIT_F}},
{72, &JitIL::fmrx}, //"fmrx", OPTYPE_FPU, FL_RC_BIT_F}}, {72, &JitIL::fmrx}, //"fmrx", OPTYPE_FPU, FL_RC_BIT_F}},

View File

@ -155,7 +155,7 @@ public:
void fselx(UGeckoInstruction inst); void fselx(UGeckoInstruction inst);
void fsubsx(UGeckoInstruction inst); void fsubsx(UGeckoInstruction inst);
void fsubx(UGeckoInstruction inst); void fsubx(UGeckoInstruction inst);
void fcmpx(UGeckoInstruction inst); void fcmpX(UGeckoInstruction inst);
void frspx(UGeckoInstruction inst); void frspx(UGeckoInstruction inst);
void fctiwzx(UGeckoInstruction inst); void fctiwzx(UGeckoInstruction inst);
void fdivx(UGeckoInstruction inst); void fdivx(UGeckoInstruction inst);

View File

@ -362,10 +362,11 @@ void JitArm64::frspx(UGeckoInstruction inst)
m_float_emit.FCVT(64, 32, EncodeRegToDouble(VD), EncodeRegToDouble(VD)); m_float_emit.FCVT(64, 32, EncodeRegToDouble(VD), EncodeRegToDouble(VD));
} }
void JitArm64::fcmpx(UGeckoInstruction inst) void JitArm64::fcmpX(UGeckoInstruction inst)
{ {
INSTRUCTION_START INSTRUCTION_START
JITDISABLE(bJITFloatingPointOff); JITDISABLE(bJITFloatingPointOff);
FALLBACK_IF(SConfig::GetInstance().bFPRF && js.op->wantsFPRF);
u32 a = inst.FA, b = inst.FB; u32 a = inst.FA, b = inst.FB;
int crf = inst.CRFD; int crf = inst.CRFD;
@ -376,27 +377,12 @@ void JitArm64::fcmpx(UGeckoInstruction inst)
ARM64Reg WA = gpr.GetReg(); ARM64Reg WA = gpr.GetReg();
ARM64Reg XA = EncodeRegTo64(WA); ARM64Reg XA = EncodeRegTo64(WA);
FixupBranch pNaN1, pNaN2, pNaN3, pLesser, pGreater; FixupBranch pNaN, pLesser, pGreater;
FixupBranch continue1, continue2, continue3; FixupBranch continue1, continue2, continue3;
ORR(XA, ZR, 32, 0, true); ORR(XA, ZR, 32, 0, true);
if (a != b)
{
m_float_emit.FCMP(EncodeRegToDouble(VA), EncodeRegToDouble(VA));
// if (B != B) or (A != A), goto NaN's jump target
pNaN1 = B(CC_NEQ);
m_float_emit.FCMP(EncodeRegToDouble(VB), EncodeRegToDouble(VB));
pNaN2 = B(CC_NEQ);
}
m_float_emit.FCMP(EncodeRegToDouble(VA), EncodeRegToDouble(VB)); m_float_emit.FCMP(EncodeRegToDouble(VA), EncodeRegToDouble(VB));
if (a == b)
pNaN3 = B(CC_NEQ);
if (a != b) if (a != b)
{ {
// if B > A goto Greater's jump target // if B > A goto Greater's jump target
@ -405,18 +391,13 @@ void JitArm64::fcmpx(UGeckoInstruction inst)
pLesser = B(CC_MI); pLesser = B(CC_MI);
} }
pNaN = B(CC_VS);
// A == B
ORR(XA, XA, 64 - 63, 0, true); ORR(XA, XA, 64 - 63, 0, true);
continue1 = B(); continue1 = B();
if (a != b) SetJumpTarget(pNaN);
{
SetJumpTarget(pNaN1);
SetJumpTarget(pNaN2);
}
else
{
SetJumpTarget(pNaN3);
}
ORR(XA, XA, 64 - 61, 0, true); ORR(XA, XA, 64 - 61, 0, true);
ORR(XA, XA, 0, 0, true); ORR(XA, XA, 0, 0, true);
@ -433,14 +414,11 @@ void JitArm64::fcmpx(UGeckoInstruction inst)
SetJumpTarget(pLesser); SetJumpTarget(pLesser);
ORR(XA, XA, 64 - 62, 1, true); ORR(XA, XA, 64 - 62, 1, true);
ORR(XA, XA, 0, 0, true); ORR(XA, XA, 0, 0, true);
}
SetJumpTarget(continue1);
if (a != b)
{
SetJumpTarget(continue2); SetJumpTarget(continue2);
SetJumpTarget(continue3); SetJumpTarget(continue3);
} }
SetJumpTarget(continue1);
STR(INDEX_UNSIGNED, XA, X29, PPCSTATE_OFF(cr_val[0]) + (sizeof(PowerPC::ppcState.cr_val[0]) * crf)); STR(INDEX_UNSIGNED, XA, X29, PPCSTATE_OFF(cr_val[0]) + (sizeof(PowerPC::ppcState.cr_val[0]) * crf));

View File

@ -327,8 +327,8 @@ static GekkoOPTemplate table59[] =
static GekkoOPTemplate table63[] = static GekkoOPTemplate table63[] =
{ {
{264, &JitArm64::fabsx}, // fabsx {264, &JitArm64::fabsx}, // fabsx
{32, &JitArm64::fcmpx}, // fcmpo {32, &JitArm64::fcmpX}, // fcmpo
{0, &JitArm64::fcmpx}, // fcmpu {0, &JitArm64::fcmpX}, // fcmpu
{14, &JitArm64::FallBackToInterpreter}, // fctiwx {14, &JitArm64::FallBackToInterpreter}, // fctiwx
{15, &JitArm64::fctiwzx}, // fctiwzx {15, &JitArm64::fctiwzx}, // fctiwzx
{72, &JitArm64::fmrx}, // fmrx {72, &JitArm64::fmrx}, // fmrx

View File

@ -102,7 +102,7 @@ public:
void fp_arith_s(UGeckoInstruction inst); void fp_arith_s(UGeckoInstruction inst);
void fcmpx(UGeckoInstruction inst); void fcmpX(UGeckoInstruction inst);
void fmrx(UGeckoInstruction inst); void fmrx(UGeckoInstruction inst);
void cmpXX(UGeckoInstruction inst); void cmpXX(UGeckoInstruction inst);

View File

@ -86,7 +86,7 @@ void JitILBase::fmrx(UGeckoInstruction inst)
ibuild.EmitStoreFReg(val, inst.FD); ibuild.EmitStoreFReg(val, inst.FD);
} }
void JitILBase::fcmpx(UGeckoInstruction inst) void JitILBase::fcmpX(UGeckoInstruction inst)
{ {
INSTRUCTION_START INSTRUCTION_START
JITDISABLE(bJITFloatingPointOff); JITDISABLE(bJITFloatingPointOff);