This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange optimization in GCC 4.7.2


Hi,

Simple code:

void somehowuse(unsigned value);

void
foo( unsigned value,
unsigned bytemask,
unsigned psw,
unsigned y)
{
unsigned x;

psw = (psw & ~(1 << 10)) | (((value >> 9) & 1) << 10);

x = (y & ~(1 << 7)) | (((value >> 9) & 1) << 7);

somehowuse(x);
somehowuse(psw);
}

Compile to assembler with gcc-4.7.2:

$ gcc -O1 -fomit-frame-pointer -S test.c -fdump-tree-all-lineno-details

Look at test.c.003t.original

unsigned int x;
psw = psw & 4294966271 | (value >> 9 & 1) << 10;
x = y & 4294967167 | (value >> 9) << 7 & 255; <--------- WAT?
somehowuse (x);
somehowuse (psw);
}

I can not understand origins of 255 bitmask here. Maybe someone can
explain? Why psw is ok and x is so spoiled?

---
With best regards, Konstantin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]