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 <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig committed 2023-09-26 20:28:01 -04:00
1 parent 45a645fbbc
commit a4de164944
1 file changed
+5 -1
@@ -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<uint8_t>(4u, Size)), Size * 8, Offset, Reg);
const auto OpSize = IR::SizeToOpSize(std::max<uint8_t>(4u, Size));
if (AllowUpperGarbage)
Reg = _Lshr(OpSize, Reg, _Constant(Offset));
else
Reg = _Bfe(OpSize, Size * 8, Offset, Reg);
}
return Reg;
}