OpcodeDispatcher: optimize 32-bit blsr

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig 2024-01-23 14:21:23 -04:00
parent 8e3d4a3e02
commit 6f11f2e6f4

View File

@ -2176,11 +2176,11 @@ void OpDispatchBuilder::BLSMSKBMIOp(OpcodeArgs) {
void OpDispatchBuilder::BLSRBMIOp(OpcodeArgs) {
// Equivalent to: (Src - 1) & Src
auto One = _Constant(1);
auto* Src = LoadSource(GPRClass, Op, Op->Src[0], Op->Flags);
auto Result = _And(OpSize::i64Bit, _Sub(OpSize::i64Bit, Src, One), Src);
LOGMAN_THROW_A_FMT(Op->InstSize >= 4, "No masking needed");
auto* Src = LoadSource(GPRClass, Op, Op->Src[0], Op->Flags, {.AllowUpperGarbage = true});
auto Size = OpSizeFromSrc(Op);
auto Result = _And(Size, _Sub(Size, Src, _Constant(1)), Src);
StoreResult(GPRClass, Op, Result, -1);
GenerateFlags_BLSR(Op, Result, Src);