This patch series rework the liveness analysis and register allocator in order to generate more optimized code, by avoiding a lot of move instructions. I have measured a 9% performance improvement in user mode and 4% in system mode.
The idea behind this patch series is to free registers as soon as the temps are not used anymore instead of waiting for a basic block end or an op with side effects. In addition temps are copied to memory as soon as they are not going to be written anymore, this way even globals can be marked as "dead", avoiding moves to a new register when inputs and outputs are aliased. Finally qemu_ld/st operations do not save back globals to memory, but only copy them there. In case of an exception the globals have the correct values, and otherwise they do not have to be reloaded. Overall this greatly reduces the number of moves emitted, and spread them all over the TBs, increasing the performances on in-order CPUs. This also reduces register spilling, especially on CPUs with few registers. In practice it means the liveness analysis is providing more information to the register allocator, and especially when to the memory version of a temp with the content of the associated register. This means that the two are now quite linked, and that for some functions the code exist in two versions, one used when the liveness analysis is enabled which only does some checks with assert(), the other when it is disabled. It might be possible to keep only one version, but it implies de-optimizing the liveness analysis disabled case. In any case the checks with assert() should be kept, as they are quite useful to make sure nothing subtly breaks. Aurelien Jarno (13): tcg: add temp_dead() tcg: add tcg_reg_sync() tcg: add temp_sync() tcg: sync output arguments on liveness request tcg: rework liveness analysis tcg: improve tcg_reg_alloc_movi() tcg: rewrite tcg_reg_alloc_mov() tcg: always mark dead input arguments as dead tcg: start with local temps in TEMP_VAL_MEM state tcg: don't explicitely save globals and temps tcg: sync globals for pure helpers instead of saving them tcg: fix some op flags tcg: rework TCG ops flags tcg/README | 15 +- tcg/tcg-opc.h | 55 ++++--- tcg/tcg.c | 443 ++++++++++++++++++++++++++++++++++++--------------------- tcg/tcg.h | 19 ++- 4 files changed, 329 insertions(+), 203 deletions(-) -- 1.7.10.4