From c362d3a9d810afffc337a0a5dad86bee68c518e9 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 12 Sep 2023 16:19:10 -0700 Subject: [PATCH 1/2] OpcodeDispatcher: Optimize 32-bit bswap Removes a redundant move, making it optimal now. --- FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index b68f33857..ec455a5e1 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -4337,7 +4337,7 @@ void OpDispatchBuilder::BSWAPOp(OpcodeArgs) { Dest = _Constant(0); } else { - Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags, -1); + Dest = LoadSource_WithOpSize(GPRClass, Op, Op->Dest, CTX->GetGPRSize(), Op->Flags, -1); Dest = _Rev(IR::SizeToOpSize(Size), Dest); } StoreResult(GPRClass, Op, Dest, -1); From 65bc159ff18e19b80f27801b3b7ca79e843fd58a Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 12 Sep 2023 16:19:55 -0700 Subject: [PATCH 2/2] InstCountCI: Update for bswap optimization --- unittests/InstructionCountCI/Secondary.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/unittests/InstructionCountCI/Secondary.json b/unittests/InstructionCountCI/Secondary.json index 62faf7608..abd7c5990 100644 --- a/unittests/InstructionCountCI/Secondary.json +++ b/unittests/InstructionCountCI/Secondary.json @@ -3705,12 +3705,11 @@ ] }, "bswap eax": { - "ExpectedInstructionCount": 2, - "Optimal": "No", + "ExpectedInstructionCount": 1, + "Optimal": "Yes", "Comment": "0x0f 0xc8", "ExpectedArm64ASM": [ - "lsr w20, w4, #0", - "rev w4, w20" + "rev w4, w4" ] }, "bswap rax": {