Hello! The testcase failed to compile with 4.5 with spill failure, but compiles OK with 4.6+. Attached patch adds the test to gcc testsuite, so the bug can be closed.
2012-09-02 Uros Bizjak <ubiz...@gmail.com> PR target/42295 * g++.dg/opt/pr42295.C: New test. Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. Uros.
Index: g++.dg/opt/pr42295.C =================================================================== --- g++.dg/opt/pr42295.C (revision 0) +++ g++.dg/opt/pr42295.C (working copy) @@ -0,0 +1,18 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-O1 -fschedule-insns -fselective-scheduling" } + +extern int f (...); + +int +testsum (void *a, int k, int n) +{ + int i, j; + + f (n / 2); + for (i = 0; i < n; i += 8) + for (j = 0; j < n; j += 8) + while (k < n) + k += 8; + + return k; +}