https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115921
--- Comment #1 from Siarhei Volkau <lis8215 at gmail dot com> --- Also take in account examples like this: uint32_t high_const_and_compare(uint32_t x) { if ( (x & 0x70000000) == 0x30000000) return do_some(); return do_other(); } It might be profitable to use right shift first there to lower constants. Now, even if you do manual optimization, GCC throws it away.