http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50257
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-01 09:27:04 UTC --- I just attached a patchlet (vs mainline, 4.6.x may require a bit of tweaking, the patch is trivial anyway) implementing the straightforward optimization for the value of 10. Please let me know how it does on your code.