aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/CodeGen/X86/PreAllocator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ARMeilleure/CodeGen/X86/PreAllocator.cs')
-rw-r--r--ARMeilleure/CodeGen/X86/PreAllocator.cs32
1 files changed, 17 insertions, 15 deletions
diff --git a/ARMeilleure/CodeGen/X86/PreAllocator.cs b/ARMeilleure/CodeGen/X86/PreAllocator.cs
index b76e9416..2f430b6f 100644
--- a/ARMeilleure/CodeGen/X86/PreAllocator.cs
+++ b/ARMeilleure/CodeGen/X86/PreAllocator.cs
@@ -154,7 +154,7 @@ namespace ARMeilleure.CodeGen.X86
// -- Doing so may allow us to encode the constant as operand 2 and avoid a copy.
// - If the constant is on operand 2, we check if the instruction supports it,
// if not, we also add a copy. 64-bits constants are usually not supported.
- if (IsCommutative(inst))
+ if (IsCommutative(operation))
{
src2 = operation.GetSource(1);
@@ -1348,16 +1348,8 @@ namespace ARMeilleure.CodeGen.X86
case Instruction.BitwiseAnd:
case Instruction.BitwiseExclusiveOr:
case Instruction.BitwiseOr:
- case Instruction.CompareEqual:
- case Instruction.CompareGreater:
- case Instruction.CompareGreaterOrEqual:
- case Instruction.CompareGreaterOrEqualUI:
- case Instruction.CompareGreaterUI:
- case Instruction.CompareLess:
- case Instruction.CompareLessOrEqual:
- case Instruction.CompareLessOrEqualUI:
- case Instruction.CompareLessUI:
- case Instruction.CompareNotEqual:
+ case Instruction.BranchIf:
+ case Instruction.Compare:
case Instruction.Multiply:
case Instruction.RotateRight:
case Instruction.ShiftLeft:
@@ -1376,18 +1368,28 @@ namespace ARMeilleure.CodeGen.X86
return false;
}
- private static bool IsCommutative(Instruction inst)
+ private static bool IsCommutative(Operation operation)
{
- switch (inst)
+ switch (operation.Instruction)
{
case Instruction.Add:
case Instruction.BitwiseAnd:
case Instruction.BitwiseExclusiveOr:
case Instruction.BitwiseOr:
- case Instruction.CompareEqual:
- case Instruction.CompareNotEqual:
case Instruction.Multiply:
return true;
+
+ case Instruction.BranchIf:
+ case Instruction.Compare:
+ {
+ Operand comp = operation.GetSource(2);
+
+ Debug.Assert(comp.Kind == OperandKind.Constant);
+
+ var compType = (Comparison)comp.AsInt32();
+
+ return compType == Comparison.Equal || compType == Comparison.NotEqual;
+ }
}
return false;