$ cat ffs.c int idx( unsigned mask ) { return __builtin_ffs( mask ) - 1; }
gcc-4.3.0-20070712: idx: bsfl %edi, %eax movl $-1, %edx cmove %edx, %eax ret gcc-4.2.2-20070802 produces worse code: idx: bsfl %edi, %edi movl $-1, %eax cmove %eax, %edi addl $1, %edi leal -1(%rdi), %eax ret -- Summary: redundant +/- 1 after __builtin_ffs() inlining. Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC target triplet: x86_64-gnu-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32994