This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/50984] Boolean return value expression clears register too often
- From: "svfuerst at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 05 Nov 2011 17:05:03 +0000
- Subject: [Bug rtl-optimization/50984] Boolean return value expression clears register too often
- Auto-submitted: auto-generated
- References: <bug-50984-4@http.gcc.gnu.org/bugzilla/>
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.)