mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-09-06 03:35:01 +00:00
Optimize %x ^ %x = 0 (#1094)
* JIT: Optimize %x ^ %x = 0 * Address feedback * Fix typo
This commit is contained in:
parent
dc144d2e19
commit
496db602ff
|
@ -12,7 +12,6 @@ namespace ARMeilleure.CodeGen.Optimizations
|
||||||
switch (operation.Instruction)
|
switch (operation.Instruction)
|
||||||
{
|
{
|
||||||
case Instruction.Add:
|
case Instruction.Add:
|
||||||
case Instruction.BitwiseExclusiveOr:
|
|
||||||
TryEliminateBinaryOpComutative(operation, 0);
|
TryEliminateBinaryOpComutative(operation, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -24,6 +23,10 @@ namespace ARMeilleure.CodeGen.Optimizations
|
||||||
TryEliminateBitwiseOr(operation);
|
TryEliminateBitwiseOr(operation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Instruction.BitwiseExclusiveOr:
|
||||||
|
TryEliminateBitwiseExclusiveOr(operation);
|
||||||
|
break;
|
||||||
|
|
||||||
case Instruction.ConditionalSelect:
|
case Instruction.ConditionalSelect:
|
||||||
TryEliminateConditionalSelect(operation);
|
TryEliminateConditionalSelect(operation);
|
||||||
break;
|
break;
|
||||||
|
@ -89,6 +92,24 @@ namespace ARMeilleure.CodeGen.Optimizations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void TryEliminateBitwiseExclusiveOr(Operation operation)
|
||||||
|
{
|
||||||
|
// Try to recognize and optimize those 2 patterns (in order):
|
||||||
|
// x ^ y == 0x00000000 when x == y
|
||||||
|
// 0x00000000 ^ y == y, x ^ 0x00000000 == x
|
||||||
|
Operand x = operation.GetSource(0);
|
||||||
|
Operand y = operation.GetSource(1);
|
||||||
|
|
||||||
|
if (x == y && x.Type.IsInteger())
|
||||||
|
{
|
||||||
|
operation.TurnIntoCopy(Const(x.Type, 0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TryEliminateBinaryOpComutative(operation, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void TryEliminateBinaryOpY(Operation operation, ulong comparand)
|
private static void TryEliminateBinaryOpY(Operation operation, ulong comparand)
|
||||||
{
|
{
|
||||||
Operand x = operation.GetSource(0);
|
Operand x = operation.GetSource(0);
|
||||||
|
|
Loading…
Reference in a new issue