https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85726
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Priority|P3 |P2 Target Milestone|--- |6.5 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. On x86 the diff from GCC 4.8 to GCC 7 at -O2 is @@ -6,8 +6,16 @@ x: .LFB0: .cfi_startproc + movl %edi, %eax + movl $715827883, %edx + imull %edx + movl %edi, %eax + sarl $31, %eax + sarl $3, %edx + subl %eax, %edx leal 15(%rdi), %eax testl %edi, %edi + movl %edx, ww(%rip) movl $1431655766, %edx cmovs %eax, %edi movl %edi, %ecx @@ -15,9 +23,9 @@ sarl $4, %ecx movl %ecx, %eax imull %edx - subl %edi, %edx - leal (%rdx,%rdx,2), %eax - movl %edx, ww(%rip) + movl %edx, %eax + subl %edi, %eax + leal (%rax,%rax,2), %eax subl %eax, %ecx movl %ecx, %eax ret