http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50984
Steven Fuerst <svfuerst at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |svfuerst at gmail dot com --- Comment #3 from Steven Fuerst <svfuerst at gmail dot com> 2011-11-05 17:05:03 UTC --- It can be done with zero clears of %eax via the magic of the lea instruction: andl $8, %edi andl $4, %esi leal (%edi, %esi, 2), %eax shr $4, %eax ret However, if the first condition is usually false, this method will be slower. On the other hand, this version can be easily manipulated to have less register pressure. (So it may always be better when the function is inevitably inlined.)