jpd002/Play--CodeGen

Info request (Idle loops)

rcaridade145 opened this issue · 1 comments

Hello.
First of all thank you for the hard work you have put into Play! and its companion projects.
You mentioned in a post that the best way to speed up would be to identify idle loops.
I'm not a compiler expert, far from it, but i do like to read on the subject (ie http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.2096&rep=rep1&type=pdf) and would like to try and help in anyway i can
Do you plan for the compiler to optimize them away? For instance something like, on very

1: mov r2 1000
2: mov r1 1
3: sub r2 r2 r1
4:test r2 0 -> will set a flag that will impact the branch
4: bf @4

Can we ignore blocks of less than a given size? Identify loops with instructions that only increment the PC? NOP like instructions?
On the example above we would still have to check if r2 was used as input for any folllowing block? Right?
Thank you

Idle loop detection needs to be done at the emulator level. In Play!, when we detect that the CPU core is idle, we greatly reduce the number of cycles to execute, giving more time to other parts of the system to execute in the time slice we're got on the host system. In other words, the code blocks that are in an idle loop are still executed, just not as often as they might be on a real system.

As for detecting the loops, I haven't found a reliable scheme to detect them: most of the time, it involves more than a simple test for a memory location.