Validate register livetime during peephole optimization
This commit is contained in:
parent
4cdc501a34
commit
3a689cc7a1
|
@ -132,6 +132,9 @@ rem @echo off
|
||||||
@call :test charwintest.c
|
@call :test charwintest.c
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
@call :test linetest.c
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :test ptrinittest.c
|
@call :test ptrinittest.c
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <gfx/bitmap.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
char * const Hires = (char *)0x4000;
|
||||||
|
Bitmap Screen;
|
||||||
|
ClipRect cr = {0, 0, 320, 200};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
bm_init(&Screen, Hires, 40, 25);
|
||||||
|
|
||||||
|
bmu_rect_clear(&Screen, 0, 0, 320, 200);
|
||||||
|
|
||||||
|
bm_line(&Screen, &cr, 0, 0, 199, 199, 0xff, LINOP_SET);
|
||||||
|
|
||||||
|
for(int i=0; i<200; i++)
|
||||||
|
{
|
||||||
|
assert(Hires[(i & 7) + 320 * (i >> 3) + (i & ~7)] == 0x80 >> (i & 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -6438,14 +6438,27 @@ bool InterCodeBasicBlock::SimplifyIntegerNumeric(const GrowingInstructionPtrArra
|
||||||
case IC_LEA:
|
case IC_LEA:
|
||||||
if (ins->mSrc[1].mTemp < 0 && ins->mSrc[0].mTemp >= 0 && ltvalue[ins->mSrc[0].mTemp])
|
if (ins->mSrc[1].mTemp < 0 && ins->mSrc[0].mTemp >= 0 && ltvalue[ins->mSrc[0].mTemp])
|
||||||
{
|
{
|
||||||
InterInstruction* ains = ltvalue[ins->mSrc[0].mTemp];
|
InterInstruction* pins = ltvalue[ins->mSrc[0].mTemp];
|
||||||
|
|
||||||
if (ains->mCode == IC_BINARY_OPERATOR && ains->mOperator == IA_ADD && ains->mSrc[0].mTemp < 0)
|
if (pins->mCode == IC_BINARY_OPERATOR && pins->mOperator == IA_ADD && pins->mSrc[0].mTemp < 0 && pins->mDst.mType == IT_INT16)
|
||||||
{
|
{
|
||||||
ins->mSrc[0] = ains->mSrc[1];
|
ins->mSrc[0] = pins->mSrc[1];
|
||||||
ins->mSrc[1].mIntConst += ains->mSrc[0].mIntConst;
|
ins->mSrc[1].mIntConst += pins->mSrc[0].mIntConst;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
#if 1
|
||||||
|
else if (pins->mCode == IC_CONVERSION_OPERATOR && pins->mOperator == IA_EXT8TO16U && pins->mSrc[0].IsUByte() && pins->mSrc[0].mTemp >= 0 && ltvalue[pins->mSrc[0].mTemp])
|
||||||
|
{
|
||||||
|
InterInstruction* ains = ltvalue[pins->mSrc[0].mTemp];
|
||||||
|
|
||||||
|
if (ains->mCode == IC_BINARY_OPERATOR && ains->mOperator == IA_ADD && ains->mSrc[0].mTemp < 0 && ains->mDst.mType == IT_INT16)
|
||||||
|
{
|
||||||
|
ins->mSrc[0] = ains->mSrc[1];
|
||||||
|
ins->mSrc[1].mIntConst += ains->mSrc[0].mIntConst;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -10492,6 +10505,9 @@ void InterCodeProcedure::Close(void)
|
||||||
DisassembleDebug("Simplified range limited relational ops");
|
DisassembleDebug("Simplified range limited relational ops");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BuildTraces(false);
|
||||||
|
DisassembleDebug("Rebuilt traces");
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
GrowingInstructionPtrArray silvalues(nullptr);
|
GrowingInstructionPtrArray silvalues(nullptr);
|
||||||
int silvused;
|
int silvused;
|
||||||
|
|
|
@ -304,16 +304,16 @@ void Linker::Link(void)
|
||||||
LinkerObject* lobj = lsec->mObjects[k];
|
LinkerObject* lobj = lsec->mObjects[k];
|
||||||
if ((lobj->mFlags & LOBJF_REFERENCED) && !(lobj->mFlags & LOBJF_PLACED) && lrgn->Allocate(this, lobj) )
|
if ((lobj->mFlags & LOBJF_REFERENCED) && !(lobj->mFlags & LOBJF_PLACED) && lrgn->Allocate(this, lobj) )
|
||||||
{
|
{
|
||||||
if (lsec->mType == LST_DATA)
|
if (lsec->mType != LST_BSS || lobj->mAddress + lobj->mSize == lrgn->mStart + lrgn->mUsed)
|
||||||
lrgn->mNonzero = lrgn->mUsed;
|
|
||||||
|
|
||||||
if (lobj->mAddress + lobj->mSize == lrgn->mStart + lrgn->mUsed)
|
|
||||||
{
|
{
|
||||||
if (lobj->mAddress < lsec->mStart)
|
if (lobj->mAddress < lsec->mStart)
|
||||||
lsec->mStart = lobj->mAddress;
|
lsec->mStart = lobj->mAddress;
|
||||||
if (lobj->mAddress + lobj->mSize > lsec->mEnd)
|
if (lobj->mAddress + lobj->mSize > lsec->mEnd)
|
||||||
lsec->mEnd = lobj->mAddress + lobj->mSize;
|
lsec->mEnd = lobj->mAddress + lobj->mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lsec->mType == LST_DATA && lsec->mEnd > lrgn->mNonzero)
|
||||||
|
lrgn->mNonzero = lsec->mEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,19 +322,16 @@ void Linker::Link(void)
|
||||||
mProgramStart = 0xffff;
|
mProgramStart = 0xffff;
|
||||||
mProgramEnd = 0x0000;
|
mProgramEnd = 0x0000;
|
||||||
|
|
||||||
int address = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < mRegions.Size(); i++)
|
for (int i = 0; i < mRegions.Size(); i++)
|
||||||
{
|
{
|
||||||
LinkerRegion* lrgn = mRegions[i];
|
LinkerRegion* lrgn = mRegions[i];
|
||||||
address = lrgn->mStart + lrgn->mNonzero;
|
|
||||||
|
|
||||||
if (lrgn->mNonzero)
|
if (lrgn->mNonzero)
|
||||||
{
|
{
|
||||||
if (lrgn->mStart < mProgramStart)
|
if (lrgn->mStart < mProgramStart)
|
||||||
mProgramStart = lrgn->mStart;
|
mProgramStart = lrgn->mStart;
|
||||||
if (address > mProgramEnd)
|
if (lrgn->mNonzero > mProgramEnd)
|
||||||
mProgramEnd = address;
|
mProgramEnd = lrgn->mNonzero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -248,6 +248,7 @@ public:
|
||||||
bool MoveCLCLoadAddZPStoreUp(int at);
|
bool MoveCLCLoadAddZPStoreUp(int at);
|
||||||
bool MoveLoadAddZPStoreUp(int at);
|
bool MoveLoadAddZPStoreUp(int at);
|
||||||
bool MoveLoadShiftRotateUp(int at);
|
bool MoveLoadShiftRotateUp(int at);
|
||||||
|
bool MoveLoadShiftStoreUp(int at);
|
||||||
|
|
||||||
bool MoveCLCLoadAddZPStoreDown(int at);
|
bool MoveCLCLoadAddZPStoreDown(int at);
|
||||||
bool FindDirectAddressSumY(int at, int reg, int& apos, int& breg);
|
bool FindDirectAddressSumY(int at, int reg, int& apos, int& breg);
|
||||||
|
@ -284,6 +285,8 @@ public:
|
||||||
bool PatchGlobalAdressSumYByX(int at, int reg, const NativeCodeInstruction& ains, int addr);
|
bool PatchGlobalAdressSumYByX(int at, int reg, const NativeCodeInstruction& ains, int addr);
|
||||||
bool MergeXYSameValue(int from);
|
bool MergeXYSameValue(int from);
|
||||||
|
|
||||||
|
bool ReverseReplaceTAX(int at);
|
||||||
|
|
||||||
bool ValueForwarding(const NativeRegisterDataSet& data, bool global, bool final);
|
bool ValueForwarding(const NativeRegisterDataSet& data, bool global, bool final);
|
||||||
|
|
||||||
void CollectEntryBlocks(NativeCodeBasicBlock* block);
|
void CollectEntryBlocks(NativeCodeBasicBlock* block);
|
||||||
|
@ -330,6 +333,8 @@ public:
|
||||||
bool PatchForwardSumYPointer(const NativeCodeBasicBlock* block, int reg, int base, int index, int at, int yval);
|
bool PatchForwardSumYPointer(const NativeCodeBasicBlock* block, int reg, int base, int index, int at, int yval);
|
||||||
|
|
||||||
bool IsDominatedBy(const NativeCodeBasicBlock* block) const;
|
bool IsDominatedBy(const NativeCodeBasicBlock* block) const;
|
||||||
|
|
||||||
|
void CheckLive(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class NativeCodeProcedure
|
class NativeCodeProcedure
|
||||||
|
|
|
@ -73,7 +73,7 @@ int main2(int argc, const char** argv)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
strcpy(strProductName, "oscar64");
|
strcpy(strProductName, "oscar64");
|
||||||
strcpy(strProductVersion, "1.5.119");
|
strcpy(strProductVersion, "1.5.120");
|
||||||
|
|
||||||
#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,5,119,0
|
FILEVERSION 1,5,120,0
|
||||||
PRODUCTVERSION 1,5,119,0
|
PRODUCTVERSION 1,5,120,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.5.119.0"
|
VALUE "FileVersion", "1.5.120.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.5.119.0"
|
VALUE "ProductVersion", "1.5.120.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -4023,15 +4023,15 @@
|
||||||
{
|
{
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:oscar64"
|
"ProductName" = "8:oscar64"
|
||||||
"ProductCode" = "8:{B1BF49F7-D667-4323-99B3-BBC698F30A19}"
|
"ProductCode" = "8:{9290BC82-2F82-425B-940E-E5626BB5D5FD}"
|
||||||
"PackageCode" = "8:{4B34FDC5-E807-4B25-8603-B7969A6CF518}"
|
"PackageCode" = "8:{B19DA3BE-65E1-4E1E-B167-39662B0C378C}"
|
||||||
"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.5.119"
|
"ProductVersion" = "8:1.5.120"
|
||||||
"Manufacturer" = "8:oscar64"
|
"Manufacturer" = "8:oscar64"
|
||||||
"ARPHELPTELEPHONE" = "8:"
|
"ARPHELPTELEPHONE" = "8:"
|
||||||
"ARPHELPLINK" = "8:"
|
"ARPHELPLINK" = "8:"
|
||||||
|
|
Loading…
Reference in New Issue