http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56352
Bug #: 56352 Summary: Simplify testing of related conditions in for loop Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: josh.m.con...@gmail.com If we have a loop like this: for (i = 0; i < a && i < b; i++) { /* Code which cannot affect i, a, or b */ } gcc should be able to optimize this into: tmp = MIN(a,b) for (i = 0; i < tmp; i++) { /* Body */ } But it does not. Similarly, code like: for (i = 0; i < a; i++) { if (i >= b) break; /* Code which cannot affect i, a, or b */ } Should be similarly optimized.