gcc 3.4.x generates a bit suboptimal code on the below fragment. gcc 4.x generates code which is a bit more suboptimal. unsigned v; void g(unsigned A) /* gcc -O2 -fomit-frame-pointer -S: gcc-3.4.3, 3.4.6: movl $-858993459, %eax mull 4(%esp) movl %edx, %eax // huh? shrl $3, %eax movl %eax, v ret gcc-4.0.0,4.1.1: movl $-858993459, %eax mull 4(%esp) movl %edx, %eax // huh? xorl %edx, %edx // huh?? shrl $3, %eax movl %eax, v ret */ { v = (A * 3435973837ULL) >> 35; }
As far as I can tell this is a target issue of splitting too late.
I can confirm this in a recent build of GCC: (GNU) 4.2.0 20060913 (experimental) on i686-pc-linux-gnu.
*** This bug has been marked as a duplicate of 24929 ***