qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Richard Henderson <rth@twiddle.net>
Cc: laurent.desnogues@gmail.com, qemu-devel@nongnu.org,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH 2/2] tcg-x86_64: Avoid unnecessary REX.B prefixes.
Date: Fri, 15 Jan 2010 01:37:45 +0000	[thread overview]
Message-ID: <20100115013745.GA30105@shareable.org> (raw)
In-Reply-To: <4B4F5DEC.9090909@twiddle.net>

Richard Henderson wrote:
> On 01/14/2010 08:10 AM, Aurelien Jarno wrote:
> >With the above change, rex can be > 0xff. Not sure it's not a good idea
> >to not have an explicit cast when calling tcg_out8(), even if it
> >technically works.

> >What's the reason for removing the '&  0xff' part? tcg_out8() takes an 
> >uint8_t.
> 
> Yes, and the uint8_t truncates the value just fine.  Is there any 
> particular reason you want to clutter the code with a duplicate 
> truncation?  It might have been reasonable if the function name didn't 
> quite clearly indicate that a single byte was going to be output...

The & 0xff makes it clear that rex > 0xff is intentional; that you
have thought about it.

Otherwise it looks like rex > 0xff might be unintentional.  Anyone can
check the code isn't mistaken, but it's better if it doesn't *look*
like a mistake.  After all, there have been mistakes in this sort of
code elsewhere many times.

In this sense, I think it's not cluttering; it's removing excessive
subtlety.

I would hope that GCC optimises the & 0xff away.

-- Jamie

      parent reply	other threads:[~2010-01-15  1:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06  0:31 [Qemu-devel] [PATCH 2/2] tcg-x86_64: Avoid unnecessary REX.B prefixes Richard Henderson
2010-01-06  4:16 ` Richard Henderson
2010-01-14 16:10 ` Aurelien Jarno
2010-01-14 18:09   ` Richard Henderson
2010-01-14 18:51     ` Aurelien Jarno
2010-01-14 22:59       ` [Qemu-devel] [PATCH] " Richard Henderson
2010-01-15  8:30         ` [Qemu-devel] " Aurelien Jarno
2010-01-15  1:37     ` Jamie Lokier [this message]

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=20100115013745.GA30105@shareable.org \
    --to=jamie@shareable.org \
    --cc=aurelien@aurel32.net \
    --cc=laurent.desnogues@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).