qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 00/26] tcg: rework liveness analysis and register allocator
Date: Wed, 10 Oct 2012 09:42:07 +0200	[thread overview]
Message-ID: <20121010074207.GA7444@ohm.aurel32.net> (raw)
In-Reply-To: <50751CDF.7000300@redhat.com>

On Wed, Oct 10, 2012 at 08:59:43AM +0200, Paolo Bonzini wrote:
> Il 09/10/2012 21:55, Aurelien Jarno ha scritto:
> > 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.
> 
> Would it make any sense to express the saves as real TCG ops?  This
> would have a couple of advantages:

It depends what you mean by that. Spills are decided more or less at the
last moment (no free registers available, clobbered registers in a 
function call). If it is about calling the same code in tcg-target.c for
register spills than for TCG ops, it's doable, though it might be easier
to provide a spill immediate function.

If it's about inserting them in the TCG stream, as it is done at the
last step, ie after copy propagation and dead code elimination, it's not
really useful anymore.

> - more copy propagation and dead code elimination.  Something like this:
> 
>         mov_i64 cc_dst,rax
> 
> right now is compiled as follows:
> 
> 0x5555557ac37a:  mov    %rbp,(%r14)          # spill rax
> 0x5555557ac381:  mov    (%r14),%rbp          # load rax from memory
> 0x5555557ac38f:  mov    %rbp,0x98(%r14)      # spill cc_dst to memory

I am surprised by this kind of code, and I think there's a bug somewhere
in TCG. With the current TCG code, given rax is not dead, it should be
spilled only after the move of cc_dst to memory, and thus second line is
not supposed to be emitted. With this patch series applied the second 
line should simply be removed.

> while expressing spills as TCG ops would turn the above into effectively
> 
>         st_i64  rax, env, $0x98

Which is basically the last assembly line of your example above.

> - constant propagation using constraints.  This would let tcg-i386 use
> effectively the mov $imm,(addr) instruction for spills of known-constant
> values.

This is indeed something quite frustrating and even more when the
same immediate value is loaded multiple time. One way to do that would
be to provide an optional tcg_out_st_immediate().

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2012-10-10  7:42 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 19:55 [Qemu-devel] [PATCH v2 00/26] tcg: rework liveness analysis and register allocator Aurelien Jarno
2012-10-09 19:55 ` [Qemu-devel] [PATCH v2 01/26] tcg: add temp_dead() Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 02/26] tcg: add tcg_reg_sync() Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 03/26] tcg: add temp_sync() Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 04/26] tcg: sync output arguments on liveness request Aurelien Jarno
2012-10-10 16:22   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 05/26] tcg: rework liveness analysis Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 06/26] tcg: improve tcg_reg_alloc_movi() Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 07/26] tcg: rewrite tcg_reg_alloc_mov() Aurelien Jarno
2012-10-10 16:27   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 08/26] tcg: always mark dead input arguments as dead Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 09/26] tcg: start with local temps in TEMP_VAL_MEM state Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 10/26] tcg: don't explicitly save globals and temps Aurelien Jarno
2012-10-10 16:55   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 11/26] tcg: fix some op flags Aurelien Jarno
2012-10-10 16:56   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 12/26] tcg: forbid ld/st function to modify globals Aurelien Jarno
2012-10-10 16:57   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 13/26] tcg: synchronize globals for ops with side effects Aurelien Jarno
2012-10-10 17:01   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 14/26] tcg: rework TCG helper flags Aurelien Jarno
2012-10-09 20:04   ` Peter Maydell
2012-10-09 20:24     ` Aurelien Jarno
2012-10-10 17:12       ` Richard Henderson
2012-10-10 17:14         ` Richard Henderson
2012-10-10 17:11   ` Richard Henderson
2012-10-19 20:24     ` Aurelien Jarno
2012-10-19 22:25       ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 15/26] target-alpha: rename " Aurelien Jarno
2012-10-10 17:14   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 16/26] target-arm: " Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 17/26] target-cris: " Aurelien Jarno
2012-10-10 10:02   ` Edgar E. Iglesias
2012-10-10 10:05   ` Edgar E. Iglesias
2012-10-10 12:09     ` Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 18/26] target-i386: " Aurelien Jarno
2012-10-10 17:15   ` Richard Henderson
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 19/26] target-microblaze: " Aurelien Jarno
2012-10-10 10:03   ` Edgar E. Iglesias
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 20/26] target-mips: " Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 21/26] target-ppc: " Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 22/26] target-s390x: " Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 23/26] target-sh4: " Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 24/26] target-sparc: " Aurelien Jarno
2012-10-13  8:57   ` Blue Swirl
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 25/26] target-xtensa: " Aurelien Jarno
2012-10-09 19:56 ` [Qemu-devel] [PATCH v2 26/26] tcg: remove compatiblity call flags Aurelien Jarno
2012-10-10 17:16   ` Richard Henderson
2012-10-10  6:59 ` [Qemu-devel] [PATCH v2 00/26] tcg: rework liveness analysis and register allocator Paolo Bonzini
2012-10-10  7:42   ` Aurelien Jarno [this message]
2012-10-10  7:49     ` Paolo Bonzini
2012-10-10  8:24       ` Aurelien Jarno
2012-10-10 17:04     ` Richard Henderson
2012-10-10 17:24 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121010074207.GA7444@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).