diff --git a/autotest/autotest.bat b/autotest/autotest.bat index 2f7700b..09bf143 100644 --- a/autotest/autotest.bat +++ b/autotest/autotest.bat @@ -331,6 +331,9 @@ exit /b %errorlevel% ..\bin\oscar64 -e -O2 -xz -Oz -n %~1 @if %errorlevel% neq 0 goto :error +..\bin\oscar64 -e -O2 -Oo -n %~1 +@if %errorlevel% neq 0 goto :error + @exit /b 0 :testb @@ -370,4 +373,7 @@ exit /b %errorlevel% ..\bin\oscar64 -e -O2 -xz -Oz -n %~1 @if %errorlevel% neq 0 goto :error +..\bin\oscar64 -e -O2 -Oo -n %~1 +@if %errorlevel% neq 0 goto :error + @exit /b 0 diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 0fbfffd..162d293 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -56112,11 +56112,24 @@ void NativeCodeGenerator::OutlineFunctions(void) }); // Check for complete loop block replacement + bool trueLoop = false, falseLoop = false; + int k = 0; while (k < segs.Size() && segs[k].mStart == 0 && segs[k].mEnd == segs[k].mBlock->mIns.Size() && segs[k].mBlock->mTrueJump == segs[k].mBlock && segs[k].mBlock->mBranch == segs[0].mBlock->mBranch) k++; if (k == segs.Size()) + trueLoop = true; + else if (k == 0) + { + while (k < segs.Size() && segs[k].mStart == 0 && segs[k].mEnd == segs[k].mBlock->mIns.Size() && segs[k].mBlock->mFalseJump == segs[k].mBlock && segs[k].mBlock->mBranch == segs[0].mBlock->mBranch) + k++; + if (k == segs.Size()) + falseLoop = true; + } + + + if (trueLoop || falseLoop) { NativeCodeBasicBlock* eblock = nproc->AllocateBlock(); @@ -56127,7 +56140,8 @@ void NativeCodeGenerator::OutlineFunctions(void) for (int i = 0; i < segs.Size(); i++) { SuffixSegment& s(segs[i]); - segs[i].mBlock->mTrueJump = segs[i].mBlock->mFalseJump; + if (trueLoop) + segs[i].mBlock->mTrueJump = segs[i].mBlock->mFalseJump; segs[i].mBlock->mFalseJump = nullptr; segs[i].mBlock->mBranch = ASMIT_JMP; segs[i].mBlock->mNumEntries = 1; @@ -56157,6 +56171,23 @@ void NativeCodeGenerator::OutlineFunctions(void) mProcedures.Push(nproc); + if (trueLoop || falseLoop) + { + ExpandingArray procs; + + for (int i = 0; i < segs.Size(); i++) + { + SuffixSegment& s(segs[i]); + NativeCodeProcedure* p = s.mBlock->mProc; + if (!procs.Contains(p)) + { + procs.Push(p); + p->ResetVisited(); + p->mEntryBlock->MergeBasicBlocks(); + } + } + } + numOutlines++; progress = true; }