Optimize do; while(!...) from two bytecodes to one

This revealed that the code for setting Par.i was wrong before, but didn't
matter because the jump target for all CONDN was set afterwards. But the
jumptarget for COND was set directly, and must be adjusted to account for
the bytecode that gets optimized away.
liquid_container
Günther Brammer 2016-01-17 01:12:23 +01:00
parent 168ac8bb40
commit 532b47ed27
1 changed files with 4 additions and 4 deletions

View File

@ -983,11 +983,11 @@ int C4AulParse::AddBCC(C4AulBCCType eType, intptr_t X)
return Fn->GetCodePos() - 1;
}
// Reduce Not + CONDN to COND
if(eType == AB_CONDN && pCPos1->bccType == AB_Not)
// Reduce Not + CONDN to COND, Not + COND to CONDN
if((eType == AB_CONDN || eType == AB_COND) && pCPos1->bccType == AB_Not)
{
pCPos1->bccType = AB_COND;
pCPos1->Par.i = X;
pCPos1->bccType = eType == AB_CONDN ? AB_COND : AB_CONDN;
pCPos1->Par.i = X + 1;
return Fn->GetCodePos() - 1;
}