spin2cpp icon indicating copy to clipboard operation
spin2cpp copied to clipboard

P2ASM opt: SKIPF as fast forward branch

Open Wuerfel21 opened this issue 3 years ago • 2 comments

This is just something I thought of today, that, from a cursory glance, the optimizer isn't doing yet. I'm not familiar with the ASM optimizer and it's past midnight, so I'm just throwing this out here RN.

Basically, when optimizing hubexec code, a forward JMP that goes over 6 or less instructions can be replaced by a SKIP/SKIPF with constant pattern to mitigate the FIFO flush (skipping 6 ops is 14 cycles, branch is 13..20 => save up to 6 cycles, more when skipping less than 6).

Similar thing works in cog code, skipping over up to 6 ops is 2 cycles faster than a branch, but one unrelated instruction has to be reordered after the SKIPF since the first instr can not be fast skipped. That's harder to implement, I think, and the gain is lower, so idk.

Wuerfel21 avatar Aug 31 '21 22:08 Wuerfel21

That's a good idea, thanks!

totalspectrum avatar Sep 02 '21 17:09 totalspectrum

I'm not sure SKIPF will be as helpful any more, since the conditional execution changes to make that more aggressive.

totalspectrum avatar Aug 24 '22 18:08 totalspectrum