Skip to content

Commit

Permalink
OpcodeDispatcher: optimize ptest with tst
Browse files Browse the repository at this point in the history
a win with flagm, a wash without

Signed-off-by: Alyssa Rosenzweig <[email protected]>
  • Loading branch information
alyssarosenzweig committed Jan 22, 2024
1 parent 950e01e commit 59e5653
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4591,20 +4591,18 @@ void OpDispatchBuilder::PTestOp(OpcodeArgs) {
auto ZeroConst = _Constant(0);
auto OneConst = _Constant(1);

Test1 = _Select(FEXCore::IR::COND_EQ,
Test1, ZeroConst, OneConst, ZeroConst);

Test2 = _Select(FEXCore::IR::COND_EQ,
Test2, ZeroConst, OneConst, ZeroConst);

// Careful, these flags are different between {V,}PTEST and VTESTP{S,D}
ZeroNZCV();
SetRFLAG<FEXCore::X86State::RFLAG_ZF_RAW_LOC>(Test1);
// Set ZF according to Test1. This may inadvently set SF, so zero that.
SetNZ_ZeroCV(32, Test1);
SetRFLAG<FEXCore::X86State::RFLAG_CF_RAW_LOC>(Test2);

uint32_t FlagsMaskToZero =
(1U << X86State::RFLAG_PF_RAW_LOC) |
(1U << X86State::RFLAG_AF_RAW_LOC);
(1U << X86State::RFLAG_AF_RAW_LOC) |
(1U << X86State::RFLAG_SF_RAW_LOC);

ZeroMultipleFlags(FlagsMaskToZero);
}
Expand Down

0 comments on commit 59e5653

Please sign in to comment.