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 00:09:29 -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 00:09 -------
I've got a patch.
/* There are four cases to handle modulo whether FLAG appears
positively and ordering of operands TARGET and MASK in the
expression.
With my patch, gcc -O2 -fomit-frame-pointer -mregparm=3 generates
the following assembly code. */
typedef _Bool bool;
unsigned long
cond_mask_0 (bool flag, unsigned long mask, unsigned long target)
{
return flag ? target | mask : target & ~mask;
#if 0
movzbl %al, %eax
decl %eax
xorl %eax, %ecx
orl %edx, %ecx
xorl %ecx, %eax
#endif
}
unsigned long
cond_mask_1 (bool flag, unsigned long mask, unsigned long target)
{
return flag ? target | ~mask : target & mask;
#if 0
movzbl %al, %eax
negl %eax
xorl %eax, %ecx
andl %edx, %ecx
xorl %ecx, %eax
#endif
}
unsigned long
cond_mask_2 (bool flag, unsigned long mask, unsigned long target)
{
return flag ? target & mask : target | ~mask;
#if 0
movzbl %al, %eax
decl %eax
xorl %eax, %ecx
andl %edx, %ecx
xorl %ecx, %eax
#endif
}
unsigned long
cond_mask_3 (bool flag, unsigned long mask, unsigned long target)
{
return flag ? target & ~mask : target | mask;
#if 0
movzbl %al, %eax
negl %eax
xorl %eax, %ecx
orl %edx, %ecx
xorl %ecx, %eax
#endif
}
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |kazu at cs dot umass dot edu
AssignedTo|unassigned at gcc dot gnu |kazu at cs dot umass dot edu
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14504