From 349bc9efab044b65701f75721e47bc42f5f132a0 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 24 Jan 2024 22:18:31 -0400 Subject: [PATCH] OpcodeDispatcher: unify rcr op 1bit codepaths get additional opt for <32-bit Signed-off-by: Alyssa Rosenzweig --- .../Interface/Core/OpcodeDispatcher.cpp | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index 14b414c8e..4e8e69694 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -2377,38 +2377,31 @@ void OpDispatchBuilder::RCROp1Bit(OpcodeArgs) { OrderedNode *Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags); const auto Size = GetSrcBitSize(Op); auto CF = GetRFLAG(FEXCore::X86State::RFLAG_CF_RAW_LOC); + OrderedNode *Res; uint32_t Shift = 1; if (Size == 32 || Size == 64) { // Rotate and insert CF in the upper bit - auto Res = _Extr(OpSizeFromSrc(Op), CF, Dest, Shift); - - // Our new CF will be bit (Shift - 1) of the source - SetRFLAG(Dest, Shift - 1, true); - - StoreResult(GPRClass, Op, Res, -1); - - // OF is the top two MSBs XOR'd together - SetRFLAG(_XorShift(OpSizeFromSrc(Op), Res, Res, ShiftType::LSR, 1), Size - 2, true); + Res = _Extr(OpSizeFromSrc(Op), CF, Dest, Shift); } else { // Res = Src >> Shift - OrderedNode *Res = _Bfe(OpSize::i32Bit, Size - Shift, Shift, Dest); + Res = _Bfe(OpSize::i32Bit, Size - Shift, Shift, Dest); // inject the CF Res = _Or(OpSize::i32Bit, Res, _Lshl(OpSize::i32Bit, CF, _Constant(Size, Size - Shift))); - - StoreResult(GPRClass, Op, Res, -1); - - // CF only changes if we actually shifted - // Our new CF will be bit (Shift - 1) of the source - SetRFLAG(Dest, Shift - 1, true); - - // OF is the top two MSBs XOR'd together - // Only when Shift == 1, it is undefined otherwise - SetRFLAG(_Xor(OpSize::i32Bit, _Bfe(OpSize::i32Bit, 1, Size - 1, Res), _Bfe(OpSize::i32Bit, 1, Size - 2, Res))); } + + // CF only changes if we actually shifted + // Our new CF will be bit (Shift - 1) of the source + SetRFLAG(Dest, Shift - 1, true); + + StoreResult(GPRClass, Op, Res, -1); + + // OF is the top two MSBs XOR'd together + // Only when Shift == 1, it is undefined otherwise + SetRFLAG(_XorShift(OpSize::i64Bit, Res, Res, ShiftType::LSR, 1), Size - 2, true); } void OpDispatchBuilder::RCROp8x1Bit(OpcodeArgs) {