Fix propagation of volatile memory reads in loops
This commit is contained in:
parent
53e4019ecd
commit
77010a0ab2
|
@ -7381,15 +7381,25 @@ bool InterCodeBasicBlock::SimplifyIntegerNumeric(const GrowingInstructionPtrArra
|
||||||
if (spareTemps + 2 >= ltvalue.Size())
|
if (spareTemps + 2 >= ltvalue.Size())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
InterInstruction* cins = new InterInstruction();
|
||||||
|
cins->mCode = IC_CONVERSION_OPERATOR;
|
||||||
|
cins->mOperator = IA_EXT8TO16U;
|
||||||
|
cins->mSrc[0] = ains->mSrc[1];
|
||||||
|
cins->mDst.mTemp = spareTemps++;
|
||||||
|
cins->mDst.mType = IT_INT16;
|
||||||
|
cins->mDst.mRange = ains->mSrc[1].mRange;
|
||||||
|
cins->mDst.mRange.LimitMin(0);
|
||||||
|
mInstructions.Insert(i, cins);
|
||||||
|
|
||||||
InterInstruction* nins = new InterInstruction();
|
InterInstruction* nins = new InterInstruction();
|
||||||
nins->mCode = IC_BINARY_OPERATOR;
|
nins->mCode = IC_BINARY_OPERATOR;
|
||||||
nins->mOperator = IA_SHL;
|
nins->mOperator = IA_SHL;
|
||||||
nins->mSrc[0] = ins->mSrc[0];
|
nins->mSrc[0] = ins->mSrc[0];
|
||||||
nins->mSrc[1] = ains->mSrc[1];
|
nins->mSrc[1] = cins->mDst;
|
||||||
nins->mDst.mTemp = spareTemps++;
|
nins->mDst.mTemp = spareTemps++;
|
||||||
nins->mDst.mType = IT_INT16;
|
nins->mDst.mType = IT_INT16;
|
||||||
nins->mDst.mRange = ins->mDst.mRange;
|
nins->mDst.mRange = ins->mDst.mRange;
|
||||||
mInstructions.Insert(i, nins);
|
mInstructions.Insert(i + 1, nins);
|
||||||
|
|
||||||
ins->mOperator = IA_ADD;
|
ins->mOperator = IA_ADD;
|
||||||
ins->mSrc[0] = ains->mSrc[0];
|
ins->mSrc[0] = ains->mSrc[0];
|
||||||
|
|
|
@ -3910,7 +3910,7 @@ void NativeCodeInstruction::CopyMode(const NativeCodeInstruction& ins)
|
||||||
mMode = ins.mMode;
|
mMode = ins.mMode;
|
||||||
mAddress = ins.mAddress;
|
mAddress = ins.mAddress;
|
||||||
mLinkerObject = ins.mLinkerObject;
|
mLinkerObject = ins.mLinkerObject;
|
||||||
mFlags = (mFlags & ~(NCIF_LOWER | NCIF_UPPER)) | (ins.mFlags & (NCIF_LOWER | NCIF_UPPER));
|
mFlags = (mFlags & ~(NCIF_LOWER | NCIF_UPPER)) | (ins.mFlags & (NCIF_LOWER | NCIF_UPPER | NCIF_VOLATILE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block)
|
void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block)
|
||||||
|
@ -16256,7 +16256,25 @@ bool NativeCodeBasicBlock::FindImmediateStore(int at, int reg, const NativeCodeI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::CheckPatchFail(const NativeCodeBasicBlock* block, int reg)
|
bool NativeCodeBasicBlock::CheckPatchFailUse(void)
|
||||||
|
{
|
||||||
|
if (mPatchChecked)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!mPatchFail)
|
||||||
|
{
|
||||||
|
mPatchFail = true;
|
||||||
|
|
||||||
|
if (mTrueJump && !mTrueJump->CheckPatchFailUse())
|
||||||
|
return false;
|
||||||
|
if (mFalseJump && !mFalseJump->CheckPatchFailUse())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeCodeBasicBlock::CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg)
|
||||||
{
|
{
|
||||||
if (mPatched)
|
if (mPatched)
|
||||||
return false;
|
return false;
|
||||||
|
@ -16265,9 +16283,9 @@ bool NativeCodeBasicBlock::CheckPatchFail(const NativeCodeBasicBlock* block, int
|
||||||
{
|
{
|
||||||
mPatchFail = true;
|
mPatchFail = true;
|
||||||
|
|
||||||
if (mTrueJump && !mTrueJump->CheckPatchFail(block, reg))
|
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
if (mFalseJump && !mFalseJump->CheckPatchFail(block, reg))
|
if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16289,9 +16307,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
||||||
{
|
{
|
||||||
if (mExitRequiredRegs[reg])
|
if (mExitRequiredRegs[reg])
|
||||||
{
|
{
|
||||||
if (mTrueJump && !mTrueJump->CheckPatchFail(block, reg))
|
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
if (mFalseJump && !mFalseJump->CheckPatchFail(block, reg))
|
if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -16332,9 +16350,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
||||||
{
|
{
|
||||||
if (mExitRequiredRegs[reg])
|
if (mExitRequiredRegs[reg])
|
||||||
{
|
{
|
||||||
if (mTrueJump && !mTrueJump->CheckPatchFail(block, reg))
|
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
if (mFalseJump && !mFalseJump->CheckPatchFail(block, reg))
|
if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16345,9 +16363,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
||||||
{
|
{
|
||||||
if (mExitRequiredRegs[reg])
|
if (mExitRequiredRegs[reg])
|
||||||
{
|
{
|
||||||
if (mTrueJump && !mTrueJump->CheckPatchFail(block, reg))
|
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
if (mFalseJump && !mFalseJump->CheckPatchFail(block, reg))
|
if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16612,7 +16630,7 @@ bool NativeCodeBasicBlock::CheckGlobalAddressSumYPointer(const NativeCodeBasicBl
|
||||||
if (at == 0)
|
if (at == 0)
|
||||||
{
|
{
|
||||||
if (!mEntryRequiredRegs[reg] && !mEntryRequiredRegs[reg + 1])
|
if (!mEntryRequiredRegs[reg] && !mEntryRequiredRegs[reg + 1])
|
||||||
return true;
|
return CheckPatchFailUse();
|
||||||
|
|
||||||
if (mNumEntries > 1)
|
if (mNumEntries > 1)
|
||||||
{
|
{
|
||||||
|
@ -16634,7 +16652,10 @@ bool NativeCodeBasicBlock::CheckGlobalAddressSumYPointer(const NativeCodeBasicBl
|
||||||
if (yval < 0)
|
if (yval < 0)
|
||||||
return false;
|
return false;
|
||||||
else if (!(ins.mLive & LIVE_MEM))
|
else if (!(ins.mLive & LIVE_MEM))
|
||||||
return true;
|
{
|
||||||
|
mPatchChecked = true;
|
||||||
|
return !mPatchFail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ins.mType == ASMIT_LDY && ins.mMode == ASMIM_IMMEDIATE)
|
if (ins.mType == ASMIT_LDY && ins.mMode == ASMIM_IMMEDIATE)
|
||||||
|
@ -30402,7 +30423,7 @@ void NativeCodeProcedure::RebuildEntry(void)
|
||||||
|
|
||||||
void NativeCodeProcedure::Optimize(void)
|
void NativeCodeProcedure::Optimize(void)
|
||||||
{
|
{
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "plant_draw");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "main");
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
int step = 0;
|
int step = 0;
|
||||||
|
@ -30516,7 +30537,6 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
mEntryBlock->CheckBlocks();
|
mEntryBlock->CheckBlocks();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
if (mEntryBlock->PeepHoleOptimizer(this, step))
|
if (mEntryBlock->PeepHoleOptimizer(this, step))
|
||||||
|
@ -30572,6 +30592,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
if (mEntryBlock->MergeBasicBlocks())
|
if (mEntryBlock->MergeBasicBlocks())
|
||||||
changed = true;
|
changed = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ResetEntryBlocks();
|
ResetEntryBlocks();
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
mEntryBlock->CollectEntryBlocks(nullptr);
|
mEntryBlock->CollectEntryBlocks(nullptr);
|
||||||
|
@ -30598,6 +30619,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
mEntryBlock->CheckBlocks(true);
|
mEntryBlock->CheckBlocks(true);
|
||||||
|
@ -30892,9 +30914,6 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
else
|
else
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
// if (CheckFunc && cnt == 3)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -442,7 +442,8 @@ public:
|
||||||
bool CheckShortcutPointerAddForward(int at);
|
bool CheckShortcutPointerAddForward(int at);
|
||||||
bool ShortcutPointerAddForward(void);
|
bool ShortcutPointerAddForward(void);
|
||||||
|
|
||||||
bool CheckPatchFail(const NativeCodeBasicBlock* block, int reg);
|
bool CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg);
|
||||||
|
bool CheckPatchFailUse(void);
|
||||||
|
|
||||||
bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int at, int yval);
|
bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int at, int yval);
|
||||||
bool PatchGlobalAddressSumYPointer(const NativeCodeBasicBlock* block, int reg, int at, int yval, LinkerObject * lobj, int address);
|
bool PatchGlobalAddressSumYPointer(const NativeCodeBasicBlock* block, int reg, int at, int yval, LinkerObject * lobj, int address);
|
||||||
|
|
|
@ -74,7 +74,7 @@ int main2(int argc, const char** argv)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
strcpy(strProductName, "oscar64");
|
strcpy(strProductName, "oscar64");
|
||||||
strcpy(strProductVersion, "1.10.164");
|
strcpy(strProductVersion, "1.10.165");
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
uint32_t length = sizeof(basePath);
|
uint32_t length = sizeof(basePath);
|
||||||
|
|
|
@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,10,164,0
|
FILEVERSION 1,10,165,0
|
||||||
PRODUCTVERSION 1,10,164,0
|
PRODUCTVERSION 1,10,165,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -43,12 +43,12 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "oscar64"
|
VALUE "CompanyName", "oscar64"
|
||||||
VALUE "FileDescription", "oscar64 compiler"
|
VALUE "FileDescription", "oscar64 compiler"
|
||||||
VALUE "FileVersion", "1.10.164.0"
|
VALUE "FileVersion", "1.10.165.0"
|
||||||
VALUE "InternalName", "oscar64.exe"
|
VALUE "InternalName", "oscar64.exe"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2021"
|
VALUE "LegalCopyright", "Copyright (C) 2021"
|
||||||
VALUE "OriginalFilename", "oscar64.exe"
|
VALUE "OriginalFilename", "oscar64.exe"
|
||||||
VALUE "ProductName", "oscar64"
|
VALUE "ProductName", "oscar64"
|
||||||
VALUE "ProductVersion", "1.10.164.0"
|
VALUE "ProductVersion", "1.10.165.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -4283,15 +4283,15 @@
|
||||||
{
|
{
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:oscar64"
|
"ProductName" = "8:oscar64"
|
||||||
"ProductCode" = "8:{BD8162B1-0E46-49AE-B175-3744635D30CB}"
|
"ProductCode" = "8:{FA6B070F-EBAE-4CDF-97EF-D58E25C49F74}"
|
||||||
"PackageCode" = "8:{C35B4B0B-03DD-4A60-A44F-6A3EFA3204B4}"
|
"PackageCode" = "8:{E315B6E4-249C-4D1D-86E1-E018924BC8EE}"
|
||||||
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
|
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
|
||||||
"AspNetVersion" = "8:2.0.50727.0"
|
"AspNetVersion" = "8:2.0.50727.0"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
"RemovePreviousVersions" = "11:TRUE"
|
"RemovePreviousVersions" = "11:TRUE"
|
||||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||||
"InstallAllUsers" = "11:FALSE"
|
"InstallAllUsers" = "11:FALSE"
|
||||||
"ProductVersion" = "8:1.10.164"
|
"ProductVersion" = "8:1.10.165"
|
||||||
"Manufacturer" = "8:oscar64"
|
"Manufacturer" = "8:oscar64"
|
||||||
"ARPHELPTELEPHONE" = "8:"
|
"ARPHELPTELEPHONE" = "8:"
|
||||||
"ARPHELPLINK" = "8:"
|
"ARPHELPLINK" = "8:"
|
||||||
|
|
Loading…
Reference in New Issue