TCG code generation performance fix
cover TCG code generation performance fix
Hello,
As Richard explained, the purpose of having separate gen_intermediate_code() and gen_intermediate_code_pc() functions per target is to compile-optimize gen_intermediate_code_internal() for the non-_pc case.
Multiple targets were using static rather than static inline though, fix this.
I've split these off from my refactorings so that we can backport them to stable, and I'm rebasing my argument refactoring patches on top.
No actual performance changes have been benchmarked, these changes serve more to align our targets as clear examples for new targets such as rl78 and bfin.
Regards,
Andreas
Andreas Färber (5):
target-cris: gen_intermediate_code_internal() should be inlined
target-lm32: gen_intermediate_code_internal() should be inline
target-microblaze: gen_intermediate_code_internal() should be inline
target-moxie: gen_intermediate_code_internal() should be inline
target-xtensa: gen_intermediate_code_internal() should be inline
target-cris/translate.c | 2 +- target-lm32/translate.c | 5 +++-- target-microblaze/translate.c | 2 +- target-moxie/translate.c | 2 +- target-xtensa/translate.c | 5 +++-- 5 files changed, 9 insertions(+), 7 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 1/5 target-cris: gen_intermediate_code_internal() should be inlined
--- target-cris/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-cris/translate.c +1 -1
@@ -3161,7 +3161,7 @@ static void check_breakpoint(CPUCRISState *env, DisasContext *dc)*/ /* generate intermediate code for basic block 'tb'. */ -static void +static inline void gen_intermediate_code_internal (CPUCRISState *env,TranslationBlock *tb,int search_pc) {
Signature · 1 line
1.8.1.4
PATCH 2/5 target-lm32: gen_intermediate_code_internal() should be inline
In reply to Andreas Färber--- target-lm32/translate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target-lm32/translate.c +3 -2
@@ -1011,8 +1011,9 @@ static void check_breakpoint(CPULM32State *env, DisasContext *dc) }/* generate intermediate code for basic block 'tb'. */ -static void gen_intermediate_code_internal (CPULM32State *env, -TranslationBlock *tb,int search_pc) +static inline +void gen_intermediate_code_internal (CPULM32State *env, +TranslationBlock *tb,int search_pc) {struct DisasContext ctx, *dc = &ctx;uint16_t *gen_opc_end;
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-cpu 2/5] target-lm32: gen_intermediate_code_internal() should be inline
Am Dienstag, 2. Juli 2013, 21:31:33 schrieb Andreas Färber:
Quoted 13 lines
Reported-by Richard Henderson <[email protected]>Signed-off-by Andreas Färber <[email protected]>--- target-lm32/translate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)target-lm32/translate.c +0
-0@@ -1011,8 +1011,9 @@ static void check_breakpoint(CPULM32State *env, DisasContext *dc) }
target-lm32/translate.c static void check_breakpoint(CPULM32State *env, · line 1019
Quoted 10 lines
target-lm32/translate.c +3
-2/* generate intermediate code for basic block 'tb'. */ -static void gen_intermediate_code_internal (CPULM32State *env, -TranslationBlock *tb,int search_pc) +static inline +void gen_intermediate_code_internal (CPULM32State *env, +TranslationBlock *tb,int search_pc) {struct DisasContext ctx, *dc = &ctx;uint16_t *gen_opc_end;
Signature · 1 line
michael
PATCH 3/5 target-microblaze: gen_intermediate_code_internal() should be inline
In reply to Andreas Färber--- target-microblaze/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-microblaze/translate.c +1 -1
@@ -1737,7 +1737,7 @@ static void check_breakpoint(CPUMBState *env, DisasContext *dc) }/* generate intermediate code for basic block 'tb'. */ -static void +static inline void gen_intermediate_code_internal (CPUMBState *env,TranslationBlock *tb,int search_pc) {
Signature · 1 line
1.8.1.4
PATCH 4/5 target-moxie: gen_intermediate_code_internal() should be inline
In reply to Andreas Färber--- target-moxie/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-moxie/translate.c +1 -1
@@ -820,7 +820,7 @@ static int decode_opc(MoxieCPU *cpu, DisasContext *ctx) }/* generate intermediate code for basic block 'tb'. */ -static void +static inline void gen_intermediate_code_internal (MoxieCPU *cpu,TranslationBlock *tb,bool search_pc) {
Signature · 1 line
1.8.1.4
PATCH 5/5 target-xtensa: gen_intermediate_code_internal() should be inline
In reply to Andreas Färber--- target-xtensa/translate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target-xtensa/translate.c +3 -2
@@ -2875,8 +2875,9 @@ static void gen_ibreak_check(CPUXtensaState *env, DisasContext *dc) } } -static void gen_intermediate_code_internal ( -CPUXtensaState *env,TranslationBlock *tb,int search_pc) +static inline +void gen_intermediate_code_internal (CPUXtensaState *env, +TranslationBlock *tb,int search_pc) {DisasContext dc;int insn_count =0 ;
Signature · 1 line
1.8.1.4
Quoted 6 lines · Andreas Färber
Hello,
As Richard explained, the purpose of having separate
gen_intermediate_code()andgen_intermediate_code_pc()functions per target is to compile-optimizegen_intermediate_code_internal()for the non-_pc case.
Quoted 7 lines
Multiple targets were using static rather than static inline though, fix this.
I've split these off from my refactorings so that we can backport them to stable, and I'm rebasing my argument refactoring patches on top.
No actual performance changes have been benchmarked, these changes serve more to align our targets as clear examples for new targets such as rl78 and bfin.
All:
Although we should probably do some benchmarking at some point to see if the duplicated code paths really do improve things over, say, unlikely(). But failing that we should at least have conformity of implementation.
r~
Andreas Färber
AppliedAm 02.07.2013 21:59, schrieb Richard Henderson:
Quoted 12 lines · Andreas Färber
Quoted 11 lines
Hello,
As Richard explained, the purpose of having separate
gen_intermediate_code()andgen_intermediate_code_pc()functions per target is to compile-optimizegen_intermediate_code_internal()for the non-_pc case.Multiple targets were using static rather than static inline though, fix this.
I've split these off from my refactorings so that we can backport them to stable, and I'm rebasing my argument refactoring patches on top.
Quoted 8 lines
Quoted 2 lines
No actual performance changes have been benchmarked, these changes serve more to align our targets as clear examples for new targets such as rl78 and bfin.
All:
Reviewed-by Richard Henderson <[email protected]>Although we should probably do some benchmarking at some point to see if the duplicated code paths really do improve things over, say,
unlikely().
I did wonder about unlikely() last night, but I thought that's just a branch optimization whereas inline might avoid some branches in the first place.
Quoted 1 line
But failing that we should at least have conformity of implementation.
Thanks, applied to qom-cpu (moving log_cpu_state to qom-cpu-next):
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
(If maintainers want to ack/nack, please do.)
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg