This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Strange optimization in GCC 4.7.2
- From: Konstantin Vladimirov <konstantin dot vladimirov at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 23 Jul 2013 16:16:14 +0400
- Subject: 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