http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56281
Bug #: 56281 Summary: missed VRP optimization from undefined left shift in ISO C99 Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: vincent-...@vinc17.net It seems that GCC is unaware that a left shift is undefined in ISO C99 when it yields an integer overflow. See the following testcase with -O3 -std=c99: int foo (int i) { if (i < 0) i = -i; i *= 2; if (i < 0) i++; return i; } int bar (int i) { if (i < 0) i = -i; i <<= 1; if (i < 0) i++; return i; } GCC optimizes foo() at the .065t.vrp1 step, but not bar().