http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48732
Summary: Nested loops with small iteration count gobble time in "tree reassociation" Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: arthur.j.odw...@gmail.com Created attachment 24076 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24076 Output of "gcc-4.5 -w -O1 -S test.c -Q -v" The following test case takes inordinately long to compile on my machine (Ubuntu 10.10, 64-bit), starting with gcc-4.5. cat >test.c <<EOF void func_47() { int a, b, c, d, e; for (a=0; a < 8; ++a) { for (b=0; b < 8; ++b) { for (c=0; c < 8; ++c) { for (d=0; d < 8; ++d) { int l_752[8]; int j; for (j = 0; j < 8; j++) l_752[j] = 0; } } } } } EOF time gcc -w -O1 -S test.c -Q On my machine, the timings are as follows: With gcc-4.4: real 0.027s With gcc-4.5: real 5.801s, spent 94% of that time in "tree reassociation" With trunk: real 3.567s, spent 77% of that time in "tree reassociation" The only difference in the assembly output is that gcc-4.4 uses "ret" and gcc-4.5 uses "rep ret". Adding a fifth nested loop with 8 iterations makes compilation take more than 300 seconds; I killed it at that point.