Fix loss of loop head status in native basic blocks

This commit is contained in:
drmortalwombat 2023-04-16 14:05:09 +02:00
parent e5805716e2
commit 8ede3abcab
2 changed files with 5 additions and 13 deletions

View File

@ -38900,7 +38900,6 @@ void NativeCodeProcedure::Optimize(void)
RebuildEntry();
#if 1
if (step > 3)
{
@ -39055,7 +39054,6 @@ void NativeCodeProcedure::Optimize(void)
changed = true;
}
#if 1
if (step > 0)
{
@ -39075,9 +39073,7 @@ void NativeCodeProcedure::Optimize(void)
changed = true;
#endif
ResetEntryBlocks();
ResetVisited();
mEntryBlock->CollectEntryBlocks(nullptr);
RebuildEntry();
#if _DEBUG
ResetVisited();
@ -39092,11 +39088,7 @@ void NativeCodeProcedure::Optimize(void)
}
#endif
#if 1
if (step > 5 && !changed)
{
ResetVisited();
@ -39175,7 +39167,6 @@ void NativeCodeProcedure::Optimize(void)
#endif
}
#endif
if (step > 4 && !changed)
{
ResetVisited();
@ -39292,7 +39283,6 @@ void NativeCodeProcedure::Optimize(void)
changed = true;
#endif
#if 1
if (step >= 5)
{
@ -39346,7 +39336,6 @@ void NativeCodeProcedure::Optimize(void)
changed = true;
#endif
#if 1
ResetVisited();
if (mEntryBlock->ForwardZpXIndex(step >= 5))

View File

@ -2275,15 +2275,18 @@ Expression* Parser::ParseStatement(void)
if ((initExp->mType == EX_ASSIGNMENT || initExp->mType == EX_INITIALIZATION) && initExp->mLeft->mType == EX_VARIABLE && initExp->mRight->mType == EX_CONSTANT &&
(iterateExp->mType == EX_POSTINCDEC || iterateExp->mType == EX_PREINCDEC || iterateExp->mType == EX_ASSIGNMENT && iterateExp->mToken == TK_ASSIGN_ADD && iterateExp->mRight->mType == EX_CONSTANT) &&
iterateExp->mLeft->IsSame(initExp->mLeft) &&
conditionExp->mType == EX_RELATIONAL && conditionExp->mToken == TK_LESS_THAN && conditionExp->mLeft->IsSame(initExp->mLeft) && conditionExp->mRight->mType == EX_CONSTANT)
conditionExp->mType == EX_RELATIONAL && (conditionExp->mToken == TK_LESS_THAN || conditionExp->mToken == TK_GREATER_THAN) && conditionExp->mLeft->IsSame(initExp->mLeft) && conditionExp->mRight->mType == EX_CONSTANT)
{
if (initExp->mRight->mDecValue->mType == DT_CONST_INTEGER && conditionExp->mRight->mDecValue->mType == DT_CONST_INTEGER)
{
int startValue = int(initExp->mRight->mDecValue->mInteger);
int endValue = int(conditionExp->mRight->mDecValue->mInteger);
int stepValue = 1;
if (iterateExp->mType == EX_ASSIGNMENT)
stepValue = int(iterateExp->mRight->mDecValue->mInteger);
else if (iterateExp->mToken == TK_DEC)
stepValue = -1;
if (unrollPage)
{