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


Reply via email to