From a4de1649444975ca555ea00aa2c424458c4ba094 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 26 Sep 2023 19:21:07 -0400 Subject: [PATCH] OpcodeDispatcher: Use lshr for ah/bh with AllowUpperGarbage If we ever get around to fusing ops with shifts in the ConstProp optimizer (may or may not be worthwhile), this will delete an instruction from things like "or al, bh". Even though lsr is the same speed as bfe on Firestorm, I feel if you ask for garbage you should get garbage C: Signed-off-by: Alyssa Rosenzweig --- FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index 916244db8..b3c342111 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -5167,7 +5167,11 @@ OrderedNode *OpDispatchBuilder::LoadGPRRegister(uint32_t GPR, int8_t Size, uint8 if ((!AllowUpperGarbage && (Size != GPRSize)) || Offset != 0) { // Extract the subregister if requested. - Reg = _Bfe(IR::SizeToOpSize(std::max(4u, Size)), Size * 8, Offset, Reg); + const auto OpSize = IR::SizeToOpSize(std::max(4u, Size)); + if (AllowUpperGarbage) + Reg = _Lshr(OpSize, Reg, _Constant(Offset)); + else + Reg = _Bfe(OpSize, Size * 8, Offset, Reg); } return Reg; }