The following testcase aborts with -O2 -funroll-loops, but passes with plain -O2 for me on today's trunk.
--cut here extern void abort(); void foo(int *a, int n) { int i; for (i = 0; i < n; i++) { a[i] *= 2; a[i+1] = a[i-1] + a[i-2]; } } enum {N = 16}; int a[N]; int ref[N] = {0, 1, 4, 2, 10, 12, 24, 44, 72, 136, 232, 416, 736, 1296, 2304, 2032}; int main() { int i; for (i = 0; i < N; i++) a[i] = i; foo(a + 2, N - 3); for (i = 0; i < N; i++) if (ref[i] != a[i]) abort(); return 0; } -- cut here -- Summary: Miscompile with -O2 -funroll-loops Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: abel at gcc dot gnu dot org GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39794