qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 0/6] Implement constant folding and copy propaga


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 0/6] Implement constant folding and copy propagation in TCG
Date: Fri, 20 May 2011 10:50:49 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10

On 05/20/2011 05:39 AM, Kirill Batuzov wrote:
> This series implements some basic machine-independent optimizations.  They
> simplify code and allow liveness analysis do it's work better.
> 
> Suppose we have following ARM code:
> 
>  movw    r12, #0xb6db
>  movt    r12, #0xdb6d
> 
> In TCG before optimizations we'll have:
> 
>  movi_i32 tmp8,$0xb6db
>  mov_i32 r12,tmp8
>  mov_i32 tmp8,r12
>  ext16u_i32 tmp8,tmp8
>  movi_i32 tmp9,$0xdb6d0000
>  or_i32 tmp8,tmp8,tmp9
>  mov_i32 r12,tmp8
> 
> And after optimizations we'll have this:
> 
>  movi_i32 r12,$0xdb6db6db
> 
> Here are performance evaluation results on SPEC CPU2000 integer tests in
> user-mode emulation on x86_64 host.  There were 5 runs of each test on
> reference data set.  The tables below show runtime in seconds for all these
> runs.

I totally agree that this sort of optimization is needed in TCG.  Essentially
all RISC guests have the same problem.  When emulating one RISC upon another,
the problem may be exacerbated.  E.g. Sparc on PPC -- sparc will use a 21/11
bit split of the constant, ppc will use a 16/16 split of the constant, which
results in 3 insns in the generated code where 2 would do.

You should be aware of prior work in this area by Aurelien Jarno:

  git://git.aurel32.net/qemu.git tcg-optimizations

Given that's now 2 years old, and doesn't seem to be progressing, I hope your
patch series can get things going again...

Further optimizations that are enabled by this constant propagation include
propagating the address of an absolute memory read into the TLB lookup:

  git://repo.or.cz/git/qemu/rth.git tcg-const-addr-1

Also, enabling the tcg backend to store a constant to memory directly, rather
than loading the constant to a register first.  Sorry, I forget what branch 
this is is, but one of Aurelien's.   This improves generated code density a
bit.  While it's only i386 that can store arbitrary constants directly to
memory, most of the hosts have a zero register that can be used.

Specific comments as followups to specific patches.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]