an inconsistency in generated code?

Pavel Tolkachev paultolk@yahoo.com
Wed Aug 17 01:36:00 GMT 2011


Thanks Marc!

This certainly works for my original problem. But my question is why gcc is kind of changing its mind as it generates the code for the functions I sent in my original post -- it just seems illogical.


-Pavel



----- Original Message -----
From: Marc Glisse <marc.glisse@inria.fr>
To: Pavel Tolkachev <paultolk@yahoo.com>
Cc: GCC Users List <gcc-help@gcc.gnu.org>
Sent: Tuesday, August 16, 2011 1:40 AM
Subject: Re: an inconsistency in generated code?

On Mon, 15 Aug 2011, Pavel Tolkachev wrote:

> I needed to write portable and
> fast C/C++ function to bit-negate the most significant byte of a 32-bit
> integer. Currently, my target is i386. First, I wrote this function:
>
> uint32_t
> BitNegMsb_1(uint32_t v)
> {
>   return (v & 0xFFFFFFu) | (~v &0xFF000000u);
> }

Did you try with a xor?
return v^0xFF000000u;

-- 
Marc Glisse



More information about the Gcc-help mailing list