[Bug optimization/14504] Missed Bit Twiddling Optimization
kazu at cs dot umass dot edu
gcc-bugzilla@gcc.gnu.org
Thu Mar 11 22:29:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list