aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure
diff options
context:
space:
mode:
authorLDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>2021-02-23 13:15:45 +0100
committerGitHub <noreply@github.com>2021-02-23 13:15:45 +0100
commitbcbf240d2eab2a2794224487d87519ac31016c96 (patch)
treed352060802864a34bb2c51db5aa89487f04165bc /ARMeilleure
parent0aea1e5cb01ee693bd806f29b49b40c37b256894 (diff)
PPTC: Fix unwanted propagation of a relocatable constant in a specific case. (#1990)
* Fix unwanted propagation of a relocatable constant in a specific case. * Ptc.InternalVersion = 1990 * Nit to retrigger the Checks.
Diffstat (limited to 'ARMeilleure')
-rw-r--r--ARMeilleure/CodeGen/Optimizations/ConstantFolding.cs12
-rw-r--r--ARMeilleure/CodeGen/Optimizations/Simplification.cs6
-rw-r--r--ARMeilleure/CodeGen/X86/Assembler.cs2
-rw-r--r--ARMeilleure/Translation/PTC/Ptc.cs2
4 files changed, 17 insertions, 5 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;
diff --git a/ARMeilleure/CodeGen/X86/Assembler.cs b/ARMeilleure/CodeGen/X86/Assembler.cs
index 2484e251..bab4c453 100644
--- a/ARMeilleure/CodeGen/X86/Assembler.cs
+++ b/ARMeilleure/CodeGen/X86/Assembler.cs
@@ -961,7 +961,7 @@ namespace ARMeilleure.CodeGen.X86
WriteInt32((int)imm);
}
- else if (dest != null && dest.Kind == OperandKind.Register && info.OpRImm64 != BadOp)
+ else if (dest?.Kind == OperandKind.Register && info.OpRImm64 != BadOp)
{
int? index = source.PtcIndex;
diff --git a/ARMeilleure/Translation/PTC/Ptc.cs b/ARMeilleure/Translation/PTC/Ptc.cs
index 01d0b236..266bdba6 100644
--- a/ARMeilleure/Translation/PTC/Ptc.cs
+++ b/ARMeilleure/Translation/PTC/Ptc.cs
@@ -26,7 +26,7 @@ namespace ARMeilleure.Translation.PTC
{
private const string HeaderMagicString = "PTChd\0\0\0";
- private const int InternalVersion = 1963; //! To be incremented manually for each change to the ARMeilleure project.
+ private const uint InternalVersion = 1990; //! To be incremented manually for each change to the ARMeilleure project.
private const string ActualDir = "0";
private const string BackupDir = "1";