Fixing O3 cases for gcc tests
This commit is contained in:
parent
ec95f6dc98
commit
cd5f1daaba
|
@ -5919,6 +5919,10 @@ void InterCodeBasicBlock::Append(InterInstruction * code)
|
|||
{
|
||||
assert(code->mSrc[1].mOperandSize > 0);
|
||||
}
|
||||
if (code->mCode == IC_LOAD_TEMPORARY)
|
||||
{
|
||||
assert(code->mSrc[0].mTemp >= 0);
|
||||
}
|
||||
if (code->mDst.mTemp >= 0)
|
||||
assert(code->mDst.mType != IT_NONE);
|
||||
for (int i = 0; i < code->mNumOperands; i++)
|
||||
|
@ -18727,6 +18731,11 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa
|
|||
GrowingArray<InterInstructionPtr> indexins(nullptr);
|
||||
GrowingArray<InterInstructionPtr> pindexins(nullptr);
|
||||
|
||||
|
||||
InterInstruction* cins = nullptr;
|
||||
if (mInstructions.Size() > 2 && mInstructions[mInstructions.Size() - 2]->mCode == IC_RELATIONAL_OPERATOR)
|
||||
cins = mInstructions[mInstructions.Size() - 2];
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < mInstructions.Size(); i++)
|
||||
{
|
||||
|
@ -18778,7 +18787,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa
|
|||
ins->mSrc[1].mIntConst = ins->mSrc[1].mIntConst * indexStep[ins->mSrc[0].mTemp];
|
||||
ins->mSrc[0] = ins->mDst;
|
||||
|
||||
if (tailBlock->mEntryRequiredTemps[ins->mDst.mTemp])
|
||||
if (tailBlock->mEntryRequiredTemps[ins->mDst.mTemp] && !(cins && (cins->mSrc[0].mTemp == ins->mDst.mTemp || cins->mSrc[1].mTemp == ins->mDst.mTemp)))
|
||||
{
|
||||
InterInstruction* rins = new InterInstruction(ins->mLocation, IC_BINARY_OPERATOR);
|
||||
rins->mOperator = IA_SUB;
|
||||
|
@ -18813,7 +18822,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa
|
|||
ins->mSrc[0].mIntConst = ins->mSrc[0].mIntConst * indexStep[ins->mSrc[1].mTemp];
|
||||
ins->mSrc[1] = ins->mDst;
|
||||
|
||||
if (tailBlock->mEntryRequiredTemps[ins->mDst.mTemp])
|
||||
if (tailBlock->mEntryRequiredTemps[ins->mDst.mTemp] && !(cins && (cins->mSrc[0].mTemp == ins->mDst.mTemp || cins->mSrc[1].mTemp == ins->mDst.mTemp)))
|
||||
{
|
||||
InterInstruction* rins = new InterInstruction(ins->mLocation, IC_BINARY_OPERATOR);
|
||||
rins->mOperator = IA_SUB;
|
||||
|
@ -18850,7 +18859,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa
|
|||
if (ins->mDst.mRange.mMaxState == IntegerValueRange::S_BOUND)
|
||||
ins->mDst.mRange.mMaxValue += ins->mSrc[0].mIntConst;
|
||||
|
||||
if (tailBlock->mEntryRequiredTemps[ins->mDst.mTemp])
|
||||
if (tailBlock->mEntryRequiredTemps[ins->mDst.mTemp] && !(cins && (cins->mSrc[0].mTemp == ins->mDst.mTemp || cins->mSrc[1].mTemp == ins->mDst.mTemp)))
|
||||
{
|
||||
InterInstruction* rins = new InterInstruction(ins->mLocation, IC_BINARY_OPERATOR);
|
||||
rins->mOperator = IA_SUB;
|
||||
|
@ -20011,20 +20020,22 @@ bool InterCodeBasicBlock::PeepholeReplaceOptimization(const GrowingVariableArray
|
|||
// !mInstructions[i + 1]->ReferencesTemp(mInstructions[i + 0]->mDst.mTemp) &&
|
||||
(mInstructions[i + 2]->mSrc[0].mFinal || mInstructions[i + 2]->mSrc[1].mFinal))
|
||||
{
|
||||
if (mInstructions[i + 2]->mSrc[0].mFinal)
|
||||
if (mInstructions[i + 2]->mSrc[1].mFinal)
|
||||
{
|
||||
mInstructions[i + 0]->mSrc[0].mIntConst += mInstructions[i + 1]->mSrc[0].mIntConst;
|
||||
mInstructions[i + 1]->mSrc[1].mFinal = false;
|
||||
mInstructions[i + 2]->mSrc[1] = mInstructions[i + 1]->mSrc[1];
|
||||
mInstructions[i + 2]->mSrc[0] = mInstructions[i + 1]->mSrc[1];
|
||||
mInstructions[i + 0]->mDst.mRange.Reset();
|
||||
mInstructions[i + 1]->mDst.mRange.Reset();
|
||||
mInstructions[i + 2]->mDst.mRange.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
mInstructions[i + 1]->mSrc[0].mIntConst += mInstructions[i + 0]->mSrc[0].mIntConst;
|
||||
mInstructions[i + 1]->mSrc[1].mIntConst += mInstructions[i + 0]->mSrc[0].mIntConst;
|
||||
mInstructions[i + 0]->mSrc[1].mFinal = false;
|
||||
mInstructions[i + 1]->mDst.mRange.Reset();
|
||||
mInstructions[i + 2]->mSrc[0] = mInstructions[i + 0]->mSrc[1];
|
||||
|
||||
mInstructions[i + 1]->mDst.mRange.Reset();
|
||||
mInstructions[i + 2]->mDst.mRange.Reset();
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
@ -21355,6 +21366,16 @@ void InterCodeBasicBlock::CollectGlobalReferences(NumberSet& referencedGlobals,
|
|||
else if (ins->mSrc[1].mTemp >= 0 && (ins->mSrc[1].mMemoryBase == IM_NONE || ins->mSrc[1].mMemoryBase == IM_INDIRECT))
|
||||
storesIndirect = true;
|
||||
break;
|
||||
case IC_ASSEMBLER:
|
||||
for (int i = 1; i < ins->mNumOperands; i++)
|
||||
{
|
||||
if (ins->mSrc[i].mType == IT_POINTER && ins->mSrc[i].mTemp < 0)
|
||||
{
|
||||
storesIndirect = true;
|
||||
loadsIndirect = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IC_CALL:
|
||||
case IC_CALL_NATIVE:
|
||||
if (ins->mSrc[0].mTemp < 0 && ins->mSrc[0].mLinkerObject && ins->mSrc[0].mLinkerObject->mProc)
|
||||
|
@ -22877,7 +22898,7 @@ void InterCodeProcedure::Close(void)
|
|||
{
|
||||
GrowingTypeArray tstack(IT_NONE);
|
||||
|
||||
CheckFunc = !strcmp(mIdent->mString, "foo");
|
||||
CheckFunc = !strcmp(mIdent->mString, "f");
|
||||
CheckCase = false;
|
||||
|
||||
mEntryBlock = mBlocks[0];
|
||||
|
@ -23285,6 +23306,7 @@ void InterCodeProcedure::Close(void)
|
|||
mEntryBlock->MoveLoopHeadCheckToTail();
|
||||
|
||||
#endif
|
||||
DisassembleDebug("MoveLoopHeadCheckToTail");
|
||||
|
||||
#if 1
|
||||
LoadStoreForwarding(paramMemory);
|
||||
|
@ -23757,6 +23779,8 @@ void InterCodeProcedure::Close(void)
|
|||
TempForwarding();
|
||||
} while (GlobalConstantPropagation());
|
||||
|
||||
DisassembleDebug("GlobalConstantPropagation");
|
||||
|
||||
LoadStoreForwarding(paramMemory);
|
||||
|
||||
ResetEntryBlocks();
|
||||
|
|
|
@ -4911,19 +4911,41 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
{
|
||||
ttemp = proc->AddTemporary(ttype);
|
||||
|
||||
InterInstruction* rins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD_TEMPORARY);
|
||||
rins->mSrc[0].mType = ttype;
|
||||
rins->mSrc[0].mTemp = vr.mTemp;
|
||||
rins->mDst.mType = ttype;
|
||||
rins->mDst.mTemp = ttemp;
|
||||
fblock->Append(rins);
|
||||
if (vr.mTemp >= 0)
|
||||
{
|
||||
InterInstruction* rins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD_TEMPORARY);
|
||||
rins->mSrc[0].mType = ttype;
|
||||
rins->mSrc[0].mTemp = vr.mTemp;
|
||||
rins->mDst.mType = ttype;
|
||||
rins->mDst.mTemp = ttemp;
|
||||
fblock->Append(rins);
|
||||
}
|
||||
else
|
||||
{
|
||||
InterInstruction* rins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||
rins->mConst.mType = ttype;
|
||||
rins->mDst.mType = ttype;
|
||||
rins->mDst.mTemp = ttemp;
|
||||
tblock->Append(rins);
|
||||
}
|
||||
|
||||
InterInstruction* lins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD_TEMPORARY);
|
||||
lins->mSrc[0].mType = ttype;
|
||||
lins->mSrc[0].mTemp = vl.mTemp;
|
||||
lins->mDst.mType = ttype;
|
||||
lins->mDst.mTemp = ttemp;
|
||||
tblock->Append(lins);
|
||||
if (vl.mTemp >= 0)
|
||||
{
|
||||
InterInstruction* lins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD_TEMPORARY);
|
||||
lins->mSrc[0].mType = ttype;
|
||||
lins->mSrc[0].mTemp = vl.mTemp;
|
||||
lins->mDst.mType = ttype;
|
||||
lins->mDst.mTemp = ttemp;
|
||||
tblock->Append(lins);
|
||||
}
|
||||
else
|
||||
{
|
||||
InterInstruction* lins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||
lins->mConst.mType = ttype;
|
||||
lins->mDst.mType = ttype;
|
||||
lins->mDst.mTemp = ttemp;
|
||||
tblock->Append(lins);
|
||||
}
|
||||
|
||||
tblock->Append(jins0);
|
||||
tblock->Close(eblock, nullptr);
|
||||
|
|
|
@ -1791,6 +1791,9 @@ bool NativeCodeInstruction::MayReference(const NativeCodeInstruction& ins, bool
|
|||
|
||||
if (mType == ASMIT_JSR)
|
||||
{
|
||||
if (ins.mFlags & NCIF_ALIASING)
|
||||
return true;
|
||||
|
||||
if (ins.mMode == ASMIM_ZERO_PAGE)
|
||||
return ReferencesZeroPage(ins.mAddress);
|
||||
else
|
||||
|
@ -1844,6 +1847,8 @@ bool NativeCodeInstruction::MayBeChangedOnAddress(const NativeCodeInstruction& i
|
|||
|
||||
if (ins.mType == ASMIT_JSR)
|
||||
{
|
||||
if (mFlags & NCIF_ALIASING)
|
||||
return true;
|
||||
if (mMode == ASMIM_ZERO_PAGE)
|
||||
return ins.ChangesZeroPage(mAddress);
|
||||
else if (mMode == ASMIM_IMPLIED || mMode == ASMIM_IMMEDIATE || mMode == ASMIM_IMMEDIATE_ADDRESS)
|
||||
|
@ -3950,6 +3955,7 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data, AsmInsT
|
|||
{
|
||||
data.mRegs[CPU_REG_X].mMode = NRDM_ZERO_PAGE;
|
||||
data.mRegs[CPU_REG_X].mValue = mAddress;
|
||||
data.mRegs[CPU_REG_X].mFlags = mFlags;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -4011,6 +4017,7 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data, AsmInsT
|
|||
{
|
||||
data.mRegs[CPU_REG_Y].mMode = NRDM_ZERO_PAGE;
|
||||
data.mRegs[CPU_REG_Y].mValue = mAddress;
|
||||
data.mRegs[CPU_REG_Y].mFlags = mFlags;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -4114,6 +4121,7 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data, AsmInsT
|
|||
{
|
||||
data.mRegs[mAddress].mMode = NRDM_ZERO_PAGE;
|
||||
data.mRegs[mAddress].mValue = data.mRegs[CPU_REG_X].mValue;
|
||||
data.mRegs[mAddress].mFlags = data.mRegs[CPU_REG_X].mFlags;
|
||||
}
|
||||
else if (data.mRegs[CPU_REG_X].mMode == NRDM_ABSOLUTE)
|
||||
{
|
||||
|
@ -4123,6 +4131,7 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data, AsmInsT
|
|||
{
|
||||
data.mRegs[CPU_REG_X].mMode = NRDM_ZERO_PAGE;
|
||||
data.mRegs[CPU_REG_X].mValue = mAddress;
|
||||
data.mRegs[CPU_REG_X].mFlags = mFlags;
|
||||
}
|
||||
break;
|
||||
case ASMIT_STY:
|
||||
|
@ -4136,6 +4145,7 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data, AsmInsT
|
|||
{
|
||||
data.mRegs[mAddress].mMode = NRDM_ZERO_PAGE;
|
||||
data.mRegs[mAddress].mValue = data.mRegs[CPU_REG_Y].mValue;
|
||||
data.mRegs[mAddress].mFlags = data.mRegs[CPU_REG_Y].mFlags;
|
||||
}
|
||||
else if (data.mRegs[CPU_REG_Y].mMode == NRDM_ABSOLUTE)
|
||||
{
|
||||
|
@ -18112,6 +18122,18 @@ bool NativeCodeBasicBlock::CanExchangeSegments(int start, int mid, int end)
|
|||
|
||||
if (flagsFront & flagsBack & NCIF_VOLATILE)
|
||||
return false;
|
||||
if (flagsFront & NCIF_ALIASING)
|
||||
{
|
||||
for (int i = mid; i < end; i++)
|
||||
if (mIns[i].mType == ASMIT_JSR)
|
||||
return false;
|
||||
}
|
||||
if (flagsBack & NCIF_ALIASING)
|
||||
{
|
||||
for (int i = start; i < mid; i++)
|
||||
if (mIns[i].mType == ASMIT_JSR)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usedFront & changedBack)
|
||||
return false;
|
||||
|
@ -37520,6 +37542,9 @@ bool NativeCodeBasicBlock::OptimizeSimpleLoopInvariant(NativeCodeProcedure* proc
|
|||
for (int i = 0; i < mIns.Size(); i++)
|
||||
mIns[i].mLive |= LIVE_CPU_REG_Y;
|
||||
|
||||
if (mEntryRequiredRegs[CPU_REG_X])
|
||||
mIns[ai].mLive |= LIVE_CPU_REG_X;
|
||||
|
||||
prevBlock->mIns.Push(mIns[ai]);
|
||||
mIns.Remove(ai);
|
||||
|
||||
|
@ -50589,12 +50614,18 @@ void NativeCodeBasicBlock::CheckLive(void)
|
|||
if (mFalseJump && mFalseJump->mEntryRequiredRegs.Size() > 0 && mFalseJump->mEntryRequiredRegs[CPU_REG_X] && mExitRequiredRegs.Size() > 0)
|
||||
{
|
||||
if (mFalseJump->mIns.Size() > 0 && mFalseJump->mIns[0].RequiresXReg())
|
||||
{
|
||||
assert(mExitRequiredRegs[CPU_REG_X]);
|
||||
live |= LIVE_CPU_REG_X;
|
||||
}
|
||||
}
|
||||
if (mTrueJump && mTrueJump->mEntryRequiredRegs.Size() > 0 && mTrueJump->mEntryRequiredRegs[CPU_REG_X] && mExitRequiredRegs.Size() > 0)
|
||||
{
|
||||
if (mTrueJump->mIns.Size() > 0 && mTrueJump->mIns[0].RequiresXReg())
|
||||
{
|
||||
assert(mExitRequiredRegs[CPU_REG_X]);
|
||||
live |= LIVE_CPU_REG_X;
|
||||
}
|
||||
}
|
||||
|
||||
assert(mBranch == ASMIT_RTS || (mBranch == ASMIT_JMP) == (mFalseJump == nullptr));
|
||||
|
@ -51404,7 +51435,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
|||
mInterProc = proc;
|
||||
mInterProc->mLinkerObject->mNativeProc = this;
|
||||
|
||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "setGameObjectTimedEdge_3");
|
||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "main");
|
||||
|
||||
int nblocks = proc->mBlocks.Size();
|
||||
tblocks = new NativeCodeBasicBlock * [nblocks];
|
||||
|
@ -51955,7 +51986,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
|||
|
||||
void NativeCodeProcedure::Assemble(void)
|
||||
{
|
||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "data_check");
|
||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "a");
|
||||
|
||||
if (mInterProc->mCompilerOptions & COPT_OPTIMIZE_MERGE_CALLS)
|
||||
{
|
||||
|
@ -52658,6 +52689,7 @@ void NativeCodeProcedure::Optimize(void)
|
|||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
if (!changed && (step == 5 || step == 6 || step == 19))
|
||||
{
|
||||
|
@ -53190,7 +53222,6 @@ void NativeCodeProcedure::Optimize(void)
|
|||
mEntryBlock->CheckAsmCode();
|
||||
#endif
|
||||
|
||||
|
||||
#if 1
|
||||
if (cnt > 190)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue