[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] tcg-x86_64: Avoid unnecessary REX.B prefixe
From: |
Jamie Lokier |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] tcg-x86_64: Avoid unnecessary REX.B prefixes. |
Date: |
Fri, 15 Jan 2010 01:37:45 +0000 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
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