VarAction2: Avoid turning skip on zero/LSB set sequences into jumps

This commit is contained in:
Jonathan G Rennison
2022-08-24 00:58:08 +01:00
parent 0bec49fa56
commit 916441d943

View File

@@ -2084,6 +2084,8 @@ static void OptimiseVarAction2DeterministicSpriteGroupInsertJumps(DeterministicS
uint32 special_stores[16]; uint32 special_stores[16];
uint16 special_stores_mask = 0; uint16 special_stores_mask = 0;
int j = i - 1; int j = i - 1;
int skip_count = 0;
const DeterministicSpriteGroupAdjustFlags skip_mask = adjust.adjust_flags & (DSGAF_SKIP_ON_ZERO | DSGAF_SKIP_ON_LSB_SET);
while (j >= 0) { while (j >= 0) {
DeterministicSpriteGroupAdjust &prev = group->adjusts[j]; DeterministicSpriteGroupAdjust &prev = group->adjusts[j];
@@ -2124,9 +2126,12 @@ static void OptimiseVarAction2DeterministicSpriteGroupInsertJumps(DeterministicS
ok_stores.set(prev.parameter & 0xFF, true); ok_stores.set(prev.parameter & 0xFF, true);
} }
/* Avoid creating jumps for skip on zero/LSB set sequences */
if (prev.adjust_flags & skip_mask) skip_count++;
j--; j--;
} }
if (j < i - 1) { if (j < i - 1 && (i - j) > (skip_count + 2)) {
auto mark_end_block = [&](uint index, uint inc) { auto mark_end_block = [&](uint index, uint inc) {
if (group->adjusts[index].variable == 0x7E) { if (group->adjusts[index].variable == 0x7E) {
/* Procedure call, can't mark this as an end block directly, so insert a NOOP and use that */ /* Procedure call, can't mark this as an end block directly, so insert a NOOP and use that */