All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Kirill Batuzov <batuzovk@ispras.ru>
Cc: qemu-devel@nongnu.org, zhur@ispras.ru
Subject: Re: [Qemu-devel] [PATCH v2 5/6] Do constant folding for shift	operations.
Date: Fri, 10 Jun 2011 11:02:52 -0700	[thread overview]
Message-ID: <4DF25C4C.7000700@twiddle.net> (raw)
In-Reply-To: <1307616344-27161-6-git-send-email-batuzovk@ispras.ru>

On 06/09/2011 03:45 AM, Kirill Batuzov wrote:
> +    case INDEX_op_shl_i32:
> +#if TCG_TARGET_REG_BITS == 64
> +        y &= 0xffffffff;
> +    case INDEX_op_shl_i64:
> +#endif
> +        return x << y;
> +
> +    case INDEX_op_shr_i32:
> +#if TCG_TARGET_REG_BITS == 64
> +        x &= 0xffffffff;
> +        y &= 0xffffffff;
> +    case INDEX_op_shr_i64:
> +#endif
> +        /* Assuming TCGArg to be unsigned */
> +        return x >> y;

Don't assume when you've got a uint64_t type readily available.

> +    case INDEX_op_sar_i32:
> +#if TCG_TARGET_REG_BITS == 64
> +        x &= 0xffffffff;
> +        y &= 0xffffffff;
> +#endif
> +        return (int32_t)x >> (int32_t)y;

Masks are redundant with the casts.

> +    case INDEX_op_rotr_i32:
> +#if TCG_TARGET_REG_BITS == 64
> +        x &= 0xffffffff;
> +        y &= 0xffffffff;
> +#endif
> +        x = (x << (32 - y)) | (x >> y);

Have you looked to see if this gets recognized as a rotate
by the compiler?  I suspect that it will if you use a cast
to uint32_t here, but not if it is left as a 64-bit TCGArg.

> +#if TCG_TARGET_REG_BITS == 64
> +    case INDEX_op_rotl_i64:
> +        x = (x << y) | (x >> (64 - y));
> +        return x;
> +#endif

Likewise it's probably best to cast to uint64_t here.


r~

  reply	other threads:[~2011-06-10 18:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09 10:45 [Qemu-devel] [PATCH v2 0/6] Implement constant folding and copy propagation in TCG Kirill Batuzov
2011-06-09 10:45 ` [Qemu-devel] [PATCH v2 1/6] Add TCG optimizations stub Kirill Batuzov
2011-06-09 10:45 ` [Qemu-devel] [PATCH v2 2/6] Add copy and constant propagation Kirill Batuzov
2011-06-10 17:44   ` Richard Henderson
2011-07-07 12:36     ` Kirill Batuzov
2011-06-09 10:45 ` [Qemu-devel] [PATCH v2 3/6] Do constant folding for basic arithmetic operations Kirill Batuzov
2011-06-10 17:57   ` Richard Henderson
2011-06-09 10:45 ` [Qemu-devel] [PATCH v2 4/6] Do constant folding for boolean operations Kirill Batuzov
2011-06-09 10:45 ` [Qemu-devel] [PATCH v2 5/6] Do constant folding for shift operations Kirill Batuzov
2011-06-10 18:02   ` Richard Henderson [this message]
2011-06-09 10:45 ` [Qemu-devel] [PATCH v2 6/6] Do constant folding for unary operations Kirill Batuzov
2011-06-10 18:04   ` Richard Henderson
2011-06-10 18:08 ` [Qemu-devel] [PATCH v2 0/6] Implement constant folding and copy propagation in TCG 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=4DF25C4C.7000700@twiddle.net \
    --to=rth@twiddle.net \
    --cc=batuzovk@ispras.ru \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.