https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
Georg Müller <georgmueller at gmx dot net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |georgmueller at gmx dot net --- Comment #12 from Georg Müller <georgmueller at gmx dot net> --- gcc --version gcc (GCC) 5.0.1 20150413 (Red Hat 5.0.1-0.1) When compiling the first example with -fopt-info, I see the following difference between -O2 -funroll-loops and -O3: gcc -Wall -Wextra -fopt-info -O2 -c 1.c -funroll-loops 1.c:11:5: note: loop turned into non-loop; it never loops. 1.c:11:5: note: loop with 6 iterations completely unrolled 1.c:10:3: note: loop turned into non-loop; it never loops. 1.c:10:3: note: loop with 5 iterations completely unrolled gcc -Wall -Wextra -fopt-info -O3 -c 1.c -funroll-loops 1.c:11:5: note: loop turned into non-loop; it never loops. 1.c:11:5: note: loop with 7 iterations completely unrolled 1.c: In function 'foo': 1.c:12:23: warning: array subscript is above array bounds [-Warray-bounds] bar[j - 1] = baz[j - 1]; ^ 1.c:12:23: warning: array subscript is above array bounds [-Warray-bounds] 1.c:10:3: note: loop turned into non-loop; it never loops. 1.c:10:3: note: loop with 5 iterations completely unrolled So, -O2 unrolls 6 and 5 iterations, while -O3 unrolls 7 and 5.