Fix propagation of conditions out of loops
This commit is contained in:
parent
6444ba58cf
commit
bcc5e9d362
|
@ -6,7 +6,7 @@ namespace opp {
|
||||||
ifstream::ifstream(char fnum, char device, char channel, const string & name)
|
ifstream::ifstream(char fnum, char device, char channel, const string & name)
|
||||||
{
|
{
|
||||||
this->fnum = fnum;
|
this->fnum = fnum;
|
||||||
krnio_setnam(name);
|
krnio_setnam(name.tocstr());
|
||||||
krnio_open(fnum, device, channel);
|
krnio_open(fnum, device, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17826,6 +17826,23 @@ void InterCodeBasicBlock::PeepholeOptimization(const GrowingVariableArray& stati
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
|
// Move conversion from float to int upwards
|
||||||
|
for (int i = 1; i < mInstructions.Size(); i++)
|
||||||
|
{
|
||||||
|
InterInstruction* ins(mInstructions[i]);
|
||||||
|
if (ins->mCode == IC_CONVERSION_OPERATOR && (ins->mOperator == IA_FLOAT2INT || ins->mOperator == IA_FLOAT2UINT) && ins->mSrc[0].mFinal)
|
||||||
|
{
|
||||||
|
int j = i - 1;
|
||||||
|
while (j > 0 && CanSwapInstructions(ins, mInstructions[j]))
|
||||||
|
{
|
||||||
|
SwapInstructions(mInstructions[j], ins);
|
||||||
|
mInstructions[j + 1] = mInstructions[j];
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
mInstructions[j + 1] = ins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// move div up to mod
|
// move div up to mod
|
||||||
int imod = -1, idiv = -1;
|
int imod = -1, idiv = -1;
|
||||||
for (int i = 0; i < mInstructions.Size(); i++)
|
for (int i = 0; i < mInstructions.Size(); i++)
|
||||||
|
@ -18751,6 +18768,8 @@ void InterCodeProcedure::MoveConditionsOutOfLoop(void)
|
||||||
{
|
{
|
||||||
Disassemble("MoveConditionOutOfLoop");
|
Disassemble("MoveConditionOutOfLoop");
|
||||||
|
|
||||||
|
BuildTraces(false);
|
||||||
|
|
||||||
BuildDataFlowSets();
|
BuildDataFlowSets();
|
||||||
TempForwarding();
|
TempForwarding();
|
||||||
RemoveUnusedInstructions();
|
RemoveUnusedInstructions();
|
||||||
|
@ -19398,7 +19417,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "JSONParser::Next");
|
CheckFunc = !strcmp(mIdent->mString, "_menuShowSprites");
|
||||||
CheckCase = false;
|
CheckCase = false;
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
|
@ -26915,13 +26915,14 @@ bool NativeCodeBasicBlock::JoinTAXARange(int from, int to)
|
||||||
}
|
}
|
||||||
else if (mIns[start].mType == ASMIT_LDA && mIns[start].mMode == ASMIM_ABSOLUTE_X && mIns[start + 1].ChangesAccu() && !mIns[start + 1].ChangesAddress() && !mIns[start + 1].RequiresYReg())
|
else if (mIns[start].mType == ASMIT_LDA && mIns[start].mMode == ASMIM_ABSOLUTE_X && mIns[start + 1].ChangesAccu() && !mIns[start + 1].ChangesAddress() && !mIns[start + 1].RequiresYReg())
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = from + 1; i < to; i++)
|
for (int i = from + 1; i < to; i++)
|
||||||
{
|
{
|
||||||
if (mIns[start].MayBeChangedOnAddress(mIns[i]) || mIns[start + 1].MayBeChangedOnAddress(mIns[i]))
|
if (mIns[start].MayBeChangedOnAddress(mIns[i]) || mIns[start + 1].MayBeChangedOnAddress(mIns[i]))
|
||||||
return false;
|
return false;
|
||||||
if (mIns[start + 1].RequiresCarry() && mIns[i].ChangesCarry())
|
if (mIns[start + 1].RequiresCarry() && mIns[i].ChangesCarry())
|
||||||
return false;
|
return false;
|
||||||
|
if ((mIns[start + 1].mLive & LIVE_CPU_REG_C) && mIns[i].RequiresCarry())
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int live = mIns[to].mLive;
|
int live = mIns[to].mLive;
|
||||||
|
@ -45426,7 +45427,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
||||||
{
|
{
|
||||||
mInterProc = proc;
|
mInterProc = proc;
|
||||||
|
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "test");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "_menuShowSprites");
|
||||||
|
|
||||||
int nblocks = proc->mBlocks.Size();
|
int nblocks = proc->mBlocks.Size();
|
||||||
tblocks = new NativeCodeBasicBlock * [nblocks];
|
tblocks = new NativeCodeBasicBlock * [nblocks];
|
||||||
|
|
Loading…
Reference in New Issue