dolphin-emu/dolphin — pull request #1701 by FioraAeterna (2014-12-14 21:14:34+00:00)
Title: JIT: discard values that will not be used again

This dramatically reduces register pressure in long blocks, cutting instruction
count by 5% or more in some.

This is an "unsafe" optimization: an error in the optimizer could result in
incorrect code (e.g. necessary values thrown out), not merely suboptimal code
(as in the case of the other register-usage optimizations in PPCAnalyst).

Fix an interpreter_tables mistake in the definition of srawix: srawix does not
use RB as an input. Having interpreter_tables be precisely correct is doubly
important now, given that this optimization relies on its correctness.

Also clean up and comment more of PPCAnalyst and make it more consistent.
Make sure it accounts for every possible block exit point, even exception ones,
so that the optimization is correct in all cases.

**This is a moderately dangerous optimization, so it probably needs a decent amount of testing to make sure nothing explodes.** I was also thinking there might be some way to enforce the constraints of this optimization inside the register cache (e.g. by marking a physical register as valid, but discarded, then erroring if it gets bound and loaded) to make sure problems don't occur, but there are some subtleties: for example, falling back to interpreter flushes the register cache but does not require all the values in the register cache to be correct, just the ones the interpreter uses.