aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFicture Seven <FICTURE7@gmail.com>2020-04-09 03:36:19 +0400
committerGitHub <noreply@github.com>2020-04-09 09:36:19 +1000
commit496db602ffce6234de58babac67fb6bcd45d32df (patch)
treed7d82ef36ba5d5c6dc05f4467c15fcbe7abfda20
parentdc144d2e190e03729b16e402da9c36eec5aaf53f (diff)
Optimize %x ^ %x = 0 (#1094)
* JIT: Optimize %x ^ %x = 0 * Address feedback * Fix typo
-rw-r--r--ARMeilleure/CodeGen/Optimizations/Simplification.cs23
1 files changed, 22 insertions, 1 deletions
diff --git a/ARMeilleure/CodeGen/Optimizations/Simplification.cs b/ARMeilleure/CodeGen/Optimizations/Simplification.cs
index cafc025c..7704f798 100644
--- a/ARMeilleure/CodeGen/Optimizations/Simplification.cs
+++ b/ARMeilleure/CodeGen/Optimizations/Simplification.cs
@@ -12,7 +12,6 @@ namespace ARMeilleure.CodeGen.Optimizations
switch (operation.Instruction)
{
case Instruction.Add:
- case Instruction.BitwiseExclusiveOr:
TryEliminateBinaryOpComutative(operation, 0);
break;
@@ -24,6 +23,10 @@ namespace ARMeilleure.CodeGen.Optimizations
TryEliminateBitwiseOr(operation);
break;
+ case Instruction.BitwiseExclusiveOr:
+ TryEliminateBitwiseExclusiveOr(operation);
+ break;
+
case Instruction.ConditionalSelect:
TryEliminateConditionalSelect(operation);
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)
{
Operand x = operation.GetSource(0);