OpcodeDispatcher: optimize test x, x

fewer uops now that we invert carry

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig committed 2024-08-20 21:17:08 -04:00
1 parent 894aaa980f
commit 5d613e8716
2 files changed
+23 -4

No files matched your search

@@ -1006,8 +1006,14 @@ void OpDispatchBuilder::TESTOp(OpcodeArgs) {
}
}
HandleNZ00Write();
CalculatePF(_AndWithFlags(IR::SizeToOpSize(Size), Dest, Src));
// Try to optimize out the AND.
if (Dest == Src) {
SetNZP_ZeroCV(Size, Src);
} else {
HandleNZ00Write();
CalculatePF(_AndWithFlags(IR::SizeToOpSize(Size), Dest, Src));
}
InvalidateAF();
}