[Bug rtl-optimization/50984] Boolean return value expression clears register too often
svfuerst at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Nov 5 17:05:00 GMT 2011
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.)
More information about the Gcc-bugs
mailing list