https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80852
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> --- I don't think the test on x%2 is relevant, gcc eliminates it without problem. I thought gcc had some code to recognize 1+2+3+...+n and similar patterns, but apparently not this one.