qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Kirill Batuzov <batuzovk@ispras.ru>
Cc: mj.mccormack@samsung.com, qemu-devel@nongnu.org, zhur@ispras.ru
Subject: Re: [Qemu-devel] [PATCH 2/6] Add copy and constant propagation.
Date: Fri, 20 May 2011 11:22:36 -0700	[thread overview]
Message-ID: <4DD6B16C.5090500@twiddle.net> (raw)
In-Reply-To: <4763ae5461ae14adbb6aca5c925fa0fe81f4f214.1305889001.git.batuzovk@ispras.ru>

On 05/20/2011 05:39 AM, Kirill Batuzov wrote:
> +    static tcg_target_ulong vals[TCG_MAX_TEMPS];
> +    static tcg_temp_state state[TCG_MAX_TEMPS];

Any particular reason to make these static?  It's 4-6k on the host
stack depending on sizeof tcg_target_ulong.  Large, but not excessive.
I think it's just confusing to have them static, myself.

I think it might be clearer to have these two in a structure, rather
than two separate arrays.  That does waste a bit of memory in padding
for 64-bit target, but I think it might clean up the code a bit.

>      nb_temps = s->nb_temps;
>      nb_globals = s->nb_globals;
> +    memset(state, 0, nb_temps * sizeof(tcg_temp_state));

Of course, instead of allocating static structures, you could alloca
the memory in the appropriate size...

> +        case INDEX_op_mov_i32:
> +#if TCG_TARGET_REG_BITS == 64
> +        case INDEX_op_mov_i64:
> +#endif
> +            if ((state[args[1]] == TCG_TEMP_COPY
> +                && vals[args[1]] == args[0])
> +                || args[0] == args[1]) {
> +                args += 2;
> +                gen_opc_buf[op_index] = INDEX_op_nop;
> +                break;

Here, for example, INDEX_op_nop2 would be more appropriate,
obviating the need for the arg copy loop from patch 1.

> +            if (state[args[1]] != TCG_TEMP_CONST) {
> +            } else {
> +                /* Source argument is constant.  Rewrite the operation and
> +                   let movi case handle it. */
> +            }

FWIW, I think writing positive tests is clearer than writing
negative tests.  I.e. reverse the condition and the if/else bodies.

>          case INDEX_op_brcond_i64:
>  #endif
> +            memset(state, 0, nb_temps * sizeof(tcg_temp_state));

Why are you resetting at the branch, rather than at the label?
Seems reasonable enough to handle the extended basic block when
possible...


r~

  reply	other threads:[~2011-05-20 18:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 12:39 [Qemu-devel] [PATCH 0/6] Implement constant folding and copy propagation in TCG Kirill Batuzov
2011-05-20 12:39 ` [Qemu-devel] [PATCH 1/6] Add TCG optimizations stub Kirill Batuzov
2011-05-20 18:12   ` Richard Henderson
2011-05-20 18:33     ` Richard Henderson
2011-05-20 12:39 ` [Qemu-devel] [PATCH 2/6] Add copy and constant propagation Kirill Batuzov
2011-05-20 18:22   ` Richard Henderson [this message]
2011-05-20 18:46     ` Paolo Bonzini
2011-05-20 19:41   ` Aurelien Jarno
2011-05-20 12:39 ` [Qemu-devel] [PATCH 3/6] Do constant folding for basic arithmetic operations Kirill Batuzov
2011-05-20 12:39 ` [Qemu-devel] [PATCH 4/6] Do constant folding for boolean operations Kirill Batuzov
2011-05-20 18:45   ` Richard Henderson
2011-05-20 12:39 ` [Qemu-devel] [PATCH 5/6] Do constant folding for shift operations Kirill Batuzov
2011-05-20 18:37   ` Richard Henderson
2011-05-26 12:36     ` Kirill Batuzov
2011-05-26 13:56       ` Richard Henderson
2011-05-26 19:14         ` Blue Swirl
2011-05-26 20:10           ` Richard Henderson
2011-05-26 20:25             ` Blue Swirl
2011-05-26 21:14               ` Richard Henderson
2011-05-27 15:41                 ` Jamie Lokier
2011-05-27 17:07                 ` Blue Swirl
2011-05-27 19:54                   ` Richard Henderson
2011-05-27  7:09           ` Paolo Bonzini
2011-05-20 12:39 ` [Qemu-devel] [PATCH 6/6] Do constant folding for unary operations Kirill Batuzov
2011-05-20 18:39   ` Richard Henderson
2011-05-20 17:50 ` [Qemu-devel] [PATCH 0/6] Implement constant folding and copy propagation in TCG Richard Henderson
2011-05-20 19:37   ` Aurelien Jarno
2011-05-20 23:31     ` Andreas Färber
2011-05-21  9:37       ` Laurent Desnogues
2011-05-21 10:46         ` Aurelien Jarno
2011-05-21 17:53           ` Kirill Batuzov
2011-05-20 19:35 ` Aurelien Jarno
2011-05-21 12:47   ` Dmitry Zhurikhin
2011-05-21 12:48   ` Aurelien Jarno

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=4DD6B16C.5090500@twiddle.net \
    --to=rth@twiddle.net \
    --cc=batuzovk@ispras.ru \
    --cc=mj.mccormack@samsung.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhur@ispras.ru \
    /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).