Permalink
Browse files

Fix that weird unordered compare mode, hopefully

  • Loading branch information...
hrydgard committed Jan 4, 2018
1 parent 18be23e commit 331a8f91e8b31d43dbf59dcefd705752f991cfe5
Showing with 8 additions and 4 deletions.
  1. +1 −1 Core/MIPS/IR/IRCompFPU.cpp
  2. +1 −1 Core/MIPS/IR/IRInst.h
  3. +6 −2 Core/MIPS/IR/IRInterpreter.cpp
@@ -111,7 +111,7 @@ void IRFrontend::Comp_FPUComp(MIPSOpcode op) {
IRFpCompareMode mode;
switch (opc) {
case 1: // un, ngle (unordered)
mode = IRFpCompareMode::NotEqualUnordered;
mode = IRFpCompareMode::EitherUnordered;
break;
case 2: // eq, seq (equal, ordered)
mode = IRFpCompareMode::EqualOrdered;
View
@@ -263,7 +263,7 @@ inline IROp ComparisonToExit(IRComparison comp) {
enum IRFpCompareMode {
False = 0,
NotEqualUnordered,
EitherUnordered,
EqualOrdered, // eq, seq (equal, ordered)
EqualUnordered, // ueq, ngl (equal, unordered)
LessOrdered, // olt, lt (less than, ordered)
@@ -782,9 +782,13 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
case IRFpCompareMode::False:
mips->fpcond = 0;
break;
case IRFpCompareMode::NotEqualUnordered:
mips->fpcond = mips->f[inst->src1] != mips->f[inst->src2];
case IRFpCompareMode::EitherUnordered:
{
float a = mips->f[inst->src1];
float b = mips->f[inst->src2];
mips->fpcond = !(a > b || a < b || a == b);
break;
}
case IRFpCompareMode::EqualOrdered:
case IRFpCompareMode::EqualUnordered:
mips->fpcond = mips->f[inst->src1] == mips->f[inst->src2];

0 comments on commit 331a8f9

Please sign in to comment.