diff options
Diffstat (limited to 'ARMeilleure/CodeGen/Optimizations')
| -rw-r--r-- | ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs | 12 | ||||
| -rw-r--r-- | ARMeilleure/CodeGen/Optimizations/Simplification.cs | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs b/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs index 73828140..412f6ea4 100644 --- a/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs +++ b/ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs @@ -14,7 +14,7 @@ namespace ARMeilleure.CodeGen.Optimizations return; } - if (!AreAllSourcesConstantAndCFEnabled(operation)) + if (!AreAllSourcesConstant(operation)) { return; } @@ -24,6 +24,12 @@ namespace ARMeilleure.CodeGen.Optimizations switch (operation.Instruction) { case Instruction.Add: + if (operation.GetSource(0).Relocatable || + operation.GetSource(1).Relocatable) + { + break; + } + if (type == OperandType.I32) { EvaluateBinaryI32(operation, (x, y) => x + y); @@ -252,13 +258,13 @@ namespace ARMeilleure.CodeGen.Optimizations } } - private static bool AreAllSourcesConstantAndCFEnabled(Operation operation) + private static bool AreAllSourcesConstant(Operation operation) { for (int index = 0; index < operation.SourcesCount; index++) { Operand srcOp = operation.GetSource(index); - if (srcOp.Kind != OperandKind.Constant || srcOp.Relocatable) + if (srcOp.Kind != OperandKind.Constant) { return false; } diff --git a/ARMeilleure/CodeGen/Optimizations/Simplification.cs b/ARMeilleure/CodeGen/Optimizations/Simplification.cs index 7704f798..db32e993 100644 --- a/ARMeilleure/CodeGen/Optimizations/Simplification.cs +++ b/ARMeilleure/CodeGen/Optimizations/Simplification.cs @@ -12,6 +12,12 @@ namespace ARMeilleure.CodeGen.Optimizations switch (operation.Instruction) { case Instruction.Add: + if (operation.GetSource(0).Relocatable || + operation.GetSource(1).Relocatable) + { + break; + } + TryEliminateBinaryOpComutative(operation, 0); break; |
