OpcodeDispatcher: use SETF for DEC

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig committed 2024-03-01 19:40:53 -04:00
1 parent 0ef0bb2c97
commit 11880459a5
1 file changed
+18 -1
@@ -3593,7 +3593,24 @@ void OpDispatchBuilder::DECOp(OpcodeArgs) {
}
CalculateDeferredFlags();
Result = CalculateFlags_SUB(OpSizeFromSrc(Op), Dest, OneConst, false);
if (Size < 32 && CTX->HostFeatures.SupportsFlagM) {
// Subtraction producing upper garbage
Result = _Sub(OpSize::i32Bit, Dest, OneConst);
CalculatePF(Result);
CalculateAF(Dest, OneConst);
// Correctly set NZ flags, preserving C
HandleNZCV_RMW();
_SetSmallNZV(OpSizeFromSrc(Op), Result);
// Fix up V flag. DEC overflows only when decrementing a negative and
// getting a positive. So compare the sign bits to calculate V.
_RmifNZCV(_Andn(OpSize::i32Bit, Dest, Result), Size - 1, 1);
} else {
Result = CalculateFlags_SUB(OpSizeFromSrc(Op), Dest, OneConst, false);
}
if (!IsLocked) {
StoreResult(GPRClass, Op, Result, -1);
}