Skip to contentSkip to conversation

TCG code generation performance fix

PATCH In review Andreas Färber 3 participants 9 messages Jul 2, 2013

lore
Share & tools
lore
#0 lore raw

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

Cc Richard Henderson <[email protected]>
Cc Edgar E. Iglesias <[email protected]> (cris, mblaze)
Cc Michael Walle <[email protected]> (lm32)
Cc Peter Crosthwaite <[email protected]> (mblaze)
Cc Anthony Green <[email protected]> (moxie)
Cc Max Filippov <[email protected]> (xtensa)
Cc Mike Frysinger <[email protected]> (bfin)

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
#1 lore raw

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
index 09d0d2b..ee9ae22 100644
@@ -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
#2 lore raw

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
index 227a801..7d82dc7 100644
@@ -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
Acked-by on v1 2/5
#3 lore raw

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
---
 target-lm32/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target-lm32/translate.c +0 -0
index 227a801..7d82dc7 100644
@@ -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
#4 lore raw

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
index 54f439f..27da4bf 100644
@@ -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
#5 lore raw

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
index b0ae38a..664d359 100644
@@ -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
#6 lore raw

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
index dcb90a5..e384812 100644
@@ -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
Reviewed-by on the v1 series
#7 lore raw
In reply to Andreas Färber
Quoted 6 lines · Andreas Färber

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.

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~

author Applied
#8 lore raw

Am 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() 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.

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:

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