The following 2 functions should be compiled to the same assembly. This is one of Briggs' compiler benchmarks.
void motion_test10(int *data) { int j; int p = data[1]; int i = data[0]; do { if (p) j = 1; else j = 2; i = i + j; data[data[2]] = 2; } while (i < data[3]); } void motion_result10(int *data) { int j; int p = data[1]; int i = data[0]; if (p) j = 1; else j = 2; do { i = i + j; data[data[2]] = 2; } while (i < data[3]); } -- Summary: missed code motion optimization (invariant control structures) Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dann at godzilla dot ics dot uci dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30104