http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46186
--- Comment #17 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2010-10-26 18:53:49 UTC --- Note that clang seems to know the general result: \sum_{i=a}^b p(i)=P(b), where p(i) is a given polynomial of degree n and P(x) a polynomial of degree n+1 such that P(x)=P(x-1)+p(x) and P(a)=p(a). At least clang is able to remove the loop for sum5 += a*a*a*a*a + 2*a*a*a +5*a;