diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index aef7482c9..fd602711b 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -894,13 +894,12 @@ OrderedNode *OpDispatchBuilder::SelectCC(uint8_t OP, IR::OpSize ResultSize, Orde break; } case 0xA: { // JP - Jump if PF == 1 - SrcCond = _Select(ResultSize, OpSize::i32Bit, CondClassType{COND_EQ}, - LoadPFInverted(), ZeroConst, TrueValue, FalseValue); + // Raw value contains inverted PF in bottom bit + SrcCond = SelectMask(LoadPFRaw(), 0x1, false, ResultSize, TrueValue, FalseValue); break; } case 0xB: { // JNP - Jump if PF == 0 - SrcCond = _Select(ResultSize, OpSize::i32Bit, CondClassType{COND_NEQ}, - LoadPFInverted(), ZeroConst, TrueValue, FalseValue); + SrcCond = SelectMask(LoadPFRaw(), 0x1, true, ResultSize, TrueValue, FalseValue); break; } case 0xC: { // SF <> OF diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.h b/FEXCore/Source/Interface/Core/OpcodeDispatcher.h index e3df17fbc..4153b9b86 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.h +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.h @@ -1388,7 +1388,7 @@ private: * @name These functions are used by the deferred flag handling while it is calculating and storing flags in to RFLAGs. * @{ */ OrderedNode *LoadPF(); - OrderedNode *LoadPFInverted(); + OrderedNode *LoadPFRaw(); OrderedNode *LoadAF(); void FixupAF(); void CalculatePF(OrderedNode *Res, OrderedNode *condition = nullptr); diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Flags.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Flags.cpp index c91923feb..1390708be 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Flags.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Flags.cpp @@ -209,7 +209,7 @@ void OpDispatchBuilder::CalculateOF_Add(uint8_t SrcSize, OrderedNode *Res, Order SetRFLAG(AndOp1); } -OrderedNode *OpDispatchBuilder::LoadPFInverted() { +OrderedNode *OpDispatchBuilder::LoadPFRaw() { // Read the stored byte. This is the original 8-bit result, it needs parity calculated. auto PFByte = GetRFLAG(FEXCore::X86State::RFLAG_PF_LOC); @@ -219,14 +219,15 @@ OrderedNode *OpDispatchBuilder::LoadPFInverted() { // Calculate the popcount. auto Count = _VPopcount(1, 1, InputFPR); - auto Parity = _VExtractToGPR(8, 1, Count, 0); - - // Mask off the bottom bit only. - return _And(OpSize::i64Bit, Parity, _Constant(1)); + return _VExtractToGPR(8, 1, Count, 0); } OrderedNode *OpDispatchBuilder::LoadPF() { - return _Xor(OpSize::i32Bit, LoadPFInverted(), _Constant(1)); + // Mask off the bottom bit only. + OrderedNode *Bit = _And(OpSize::i64Bit, LoadPFRaw(), _Constant(1)); + + // Invert + return _Xor(OpSize::i32Bit, Bit, _Constant(1)); } OrderedNode *OpDispatchBuilder::LoadAF() {