This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/14504] Missed Bit Twiddling Optimization


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]