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.
This commit is contained in:
LDj3SNuD 2021-02-23 13:15:45 +01:00 committed by GitHub
parent 0aea1e5cb0
commit bcbf240d2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 6 deletions

View file

@ -14,7 +14,7 @@ namespace ARMeilleure.CodeGen.Optimizations
return; return;
} }
if (!AreAllSourcesConstantAndCFEnabled(operation)) if (!AreAllSourcesConstant(operation))
{ {
return; return;
} }
@ -24,6 +24,12 @@ namespace ARMeilleure.CodeGen.Optimizations
switch (operation.Instruction) switch (operation.Instruction)
{ {
case Instruction.Add: case Instruction.Add:
if (operation.GetSource(0).Relocatable ||
operation.GetSource(1).Relocatable)
{
break;
}
if (type == OperandType.I32) if (type == OperandType.I32)
{ {
EvaluateBinaryI32(operation, (x, y) => x + y); 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++) for (int index = 0; index < operation.SourcesCount; index++)
{ {
Operand srcOp = operation.GetSource(index); Operand srcOp = operation.GetSource(index);
if (srcOp.Kind != OperandKind.Constant || srcOp.Relocatable) if (srcOp.Kind != OperandKind.Constant)
{ {
return false; return false;
} }

View file

@ -12,6 +12,12 @@ namespace ARMeilleure.CodeGen.Optimizations
switch (operation.Instruction) switch (operation.Instruction)
{ {
case Instruction.Add: case Instruction.Add:
if (operation.GetSource(0).Relocatable ||
operation.GetSource(1).Relocatable)
{
break;
}
TryEliminateBinaryOpComutative(operation, 0); TryEliminateBinaryOpComutative(operation, 0);
break; break;

View file

@ -961,7 +961,7 @@ namespace ARMeilleure.CodeGen.X86
WriteInt32((int)imm); 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; int? index = source.PtcIndex;

View file

@ -26,7 +26,7 @@ namespace ARMeilleure.Translation.PTC
{ {
private const string HeaderMagicString = "PTChd\0\0\0"; 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 ActualDir = "0";
private const string BackupDir = "1"; private const string BackupDir = "1";

View file

@ -1235,7 +1235,7 @@
"enable_ptc": { "enable_ptc": {
"$id": "#/properties/enable_ptc", "$id": "#/properties/enable_ptc",
"type": "boolean", "type": "boolean",
"title": "Enable Profiled Persistent Translation Cache", "title": "Enable PPTC (Profiled Persistent Translation Cache)",
"description": "Enables or disables profiled translation cache persistency", "description": "Enables or disables profiled translation cache persistency",
"default": true, "default": true,
"examples": [ "examples": [