Skip to content

Commit

Permalink
Fix that weird unordered compare mode, hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 4, 2018
1 parent 18be23e commit 331a8f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Core/MIPS/IR/IRCompFPU.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/IR/IRInst.h
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions Core/MIPS/IR/IRInterpreter.cpp
Expand Up @@ -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];
Expand Down

0 comments on commit 331a8f9

Please sign in to comment.