public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/18038] New: addition in a multibit bitfield is inefficient
@ 2004-10-17  5:06 kazu at cs dot umass dot edu
  2004-10-17 16:58 ` [Bug middle-end/18038] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-10-17  5:06 UTC (permalink / raw)
  To: gcc-bugs

Consider:

struct B {
  unsigned b : 2;
};

void
store (struct B *b, int v)
{
  b->b += v;
}

./cc1 -O2 -fomit-frame-pointer -mregparm=3 generates
store:
	movb	(%eax), %cl
	andl	$3, %ecx
	addl	%edx, %ecx
	andl	$3, %ecx
	movl	(%eax), %edx
	andl	$-4, %edx
	orl	%ecx, %edx
	movl	%edx, (%eax)
	ret

We don't need two "andl".  We could do something like

store:
	movl	(%eax), %ecx
	addl	%ecx, %edx
	andl	$3, %edx
	andl	$-4, %ecx
	orl	%ecx, %edx
	movl	%edx, (%eax)
	ret

-- 
           Summary: addition in a multibit bitfield is inefficient
           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=18038


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

* [Bug middle-end/18038] addition in a multibit bitfield is inefficient
  2004-10-17  5:06 [Bug middle-end/18038] New: addition in a multibit bitfield is inefficient kazu at cs dot umass dot edu
@ 2004-10-17 16:58 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-17 16:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-17 16:58 -------
Again for PPC:
struct B {
  unsigned :30;
  unsigned b : 2;
};

Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-17 16:58:18
               date|                            |


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


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

end of thread, other threads:[~2004-10-17 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-17  5:06 [Bug middle-end/18038] New: addition in a multibit bitfield is inefficient kazu at cs dot umass dot edu
2004-10-17 16:58 ` [Bug middle-end/18038] " pinskia at gcc dot gnu dot org

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