public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/18030] New: OR is inefficient in 2-bit bitfield
@ 2004-10-16  3:04 kazu at cs dot umass dot edu
  2004-10-16  3:11 ` [Bug middle-end/18030] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-10-16  3:04 UTC (permalink / raw)
  To: gcc-bugs

Consider:

struct B {
  unsigned bit : 2;
};

void
plus (struct B *b)
{
  b->bit |= 1;
}

./cc1 -O2 -fomit-frame-pointer -mregparm=3 generates

plus:
	movb	(%eax), %cl
	andl	$3, %ecx
	orl	$1, %ecx
	andl	$3, %ecx
	movl	(%eax), %edx
	andl	$-4, %edx
	orl	%ecx, %edx
	movl	%edx, (%eax)
	ret

Note that we could just do "orl $1, (%eax)"

-- 
           Summary: OR is inefficient in 2-bit bitfield
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18030


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-03-02 16:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-16  3:04 [Bug middle-end/18030] New: OR is inefficient in 2-bit bitfield kazu at cs dot umass dot edu
2004-10-16  3:11 ` [Bug middle-end/18030] " pinskia at gcc dot gnu dot org
2004-10-16 15:49 ` kazu at cs dot umass dot edu
2004-10-17 11:26 ` giovannibajo at libero dot it
2005-01-13 18:58 ` pinskia at gcc dot gnu dot org
2005-03-02 16:05 ` cvs-commit at gcc dot gnu dot org
2005-03-02 16:08 ` kazu at cs dot umass dot edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).