Fix size heuristic of loop condition slicing
This commit is contained in:
parent
17002e4c78
commit
d4a381f71c
|
@ -12482,6 +12482,24 @@ static bool CanMoveInstructionBeforePath(const GrowingInterCodeBasicBlockPtrArra
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InterCodeBasicBlock::IsDirectLoopPathBlock(InterCodeBasicBlock* block)
|
||||||
|
{
|
||||||
|
if (this == block)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (block->mLoopHead)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (block->mEntryBlocks.Size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < block->mEntryBlocks.Size(); i++)
|
||||||
|
if (IsDirectLoopPathBlock(block->mEntryBlocks[i]))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool InterCodeBasicBlock::IsDirectDominatorBlock(InterCodeBasicBlock* block)
|
bool InterCodeBasicBlock::IsDirectDominatorBlock(InterCodeBasicBlock* block)
|
||||||
{
|
{
|
||||||
if (this == block)
|
if (this == block)
|
||||||
|
@ -15964,12 +15982,12 @@ bool InterCodeBasicBlock::MoveConditionOutOfLoop(void)
|
||||||
int ninside = 0, noutside = 0;
|
int ninside = 0, noutside = 0;
|
||||||
for (int i = 0; i < body.Size(); i++)
|
for (int i = 0; i < body.Size(); i++)
|
||||||
{
|
{
|
||||||
bool tdom = block->mTrueJump->IsDirectDominatorBlock(body[i]);
|
bool tdom = block->mTrueJump->IsDirectLoopPathBlock(body[i]);
|
||||||
bool fdom = block->mFalseJump->IsDirectDominatorBlock(body[i]);
|
bool fdom = block->mFalseJump->IsDirectLoopPathBlock(body[i]);
|
||||||
if (tdom != fdom)
|
if (tdom != fdom)
|
||||||
ninside += body[i]->mInstructions.Size();
|
ninside += body[i]->mInstructions.Size() + 1;
|
||||||
else
|
else
|
||||||
noutside += body[i]->mInstructions.Size();
|
noutside += body[i]->mInstructions.Size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Less than four instructions outside of condition, or twice as many
|
// Less than four instructions outside of condition, or twice as many
|
||||||
|
@ -21016,7 +21034,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "__drawScreen__");
|
CheckFunc = !strcmp(mIdent->mString, "test");
|
||||||
CheckCase = false;
|
CheckCase = false;
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
|
@ -531,6 +531,7 @@ public:
|
||||||
bool MoveTrainCrossBlock(void);
|
bool MoveTrainCrossBlock(void);
|
||||||
bool HoistCommonConditionalPath(void);
|
bool HoistCommonConditionalPath(void);
|
||||||
bool IsDirectDominatorBlock(InterCodeBasicBlock* block);
|
bool IsDirectDominatorBlock(InterCodeBasicBlock* block);
|
||||||
|
bool IsDirectLoopPathBlock(InterCodeBasicBlock* block);
|
||||||
|
|
||||||
void MarkRelevantStatics(void);
|
void MarkRelevantStatics(void);
|
||||||
void RemoveNonRelevantStatics(void);
|
void RemoveNonRelevantStatics(void);
|
||||||
|
|
Loading…
Reference in New Issue