mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-29 03:00:54 +01:00
OpcodeDispatcher: Optimize xor zeroing
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
1 parent
6baee3b7c1
commit
fc72fa9e5f
1 file changed
+18
-4
+18
-4
@@ -5334,11 +5334,25 @@ void OpDispatchBuilder::ALUOpImpl(OpcodeArgs, FEXCore::IR::IROps ALUIROp, FEXCor
|
||||
else {
|
||||
Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags, -1);
|
||||
|
||||
auto ALUOp = _Add(Dest, Src);
|
||||
// Overwrite our IR's op type
|
||||
ALUOp.first->Header.Op = ALUIROp;
|
||||
/* On x86, the canonical way to zero a register is XOR with itself...
|
||||
* because modern x86 detects this pattern in hardware. arm64 does not
|
||||
* detect this pattern, we should do it like the x86 hardware would. On
|
||||
* arm64, "mov x0, #0" is faster than "eor x0, x0, x0". Additionally this
|
||||
* lets more constant folding kick in for flags.
|
||||
*/
|
||||
if (ALUIROp == FEXCore::IR::IROps::OP_XOR &&
|
||||
Op->Dest.IsGPR() && Op->Src[0].IsGPR() &&
|
||||
Op->Dest.Data.GPR == Op->Src[0].Data.GPR) {
|
||||
|
||||
Result = _Constant(0);
|
||||
} else {
|
||||
auto ALUOp = _Add(Dest, Src);
|
||||
// Overwrite our IR's op type
|
||||
ALUOp.first->Header.Op = ALUIROp;
|
||||
|
||||
Result = ALUOp;
|
||||
}
|
||||
|
||||
Result = ALUOp;
|
||||
StoreResult(GPRClass, Op, Result, -1);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user