This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14504] Missed Bit Twiddling Optimization
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Mar 2004 22:29:46 -0000
- Subject: [Bug optimization/14504] Missed Bit Twiddling Optimization
- References: <20040309171658.14504.stl@caltech.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From kazu at cs dot umass dot edu 2004-03-11 22:29 -------
Err, i386 is a two-address machine with only a few registers,
so cmove doesn't work as well in this case.
typedef _Bool bool;
unsigned long
cond_mask (bool flag, unsigned long mask, unsigned long target)
{
unsigned long l = target | mask;
unsigned long r = target & ~mask;
return flag ? l : r;
#if 0
pushl %ebx
movl %eax, %ebx ; %bl = flag
movl %ecx, %eax
orl %edx, %eax ; %eax = target | mask
notl %edx ; ~mask
andl %ecx, %edx ; %edx = target & ~mask
testb %bl, %bl
popl %ebx
cmove %edx, %eax
#endif
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14504