https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71343
--- Comment #2 from SztfG at yandex dot ru --- This also not optimized by gcc: unsigned int test3(unsigned int a , unsigned int b) { return (a << 2) + (b << 2) == (a + b) << 2; } but this works: unsigned int test4(unsigned int a , unsigned int b) { return (a * 4) + (b * 4) == (a + b) * 4; } result: movl $1, %eax ret Distributive property also should work with binary shifts.