public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field
@ 2004-05-06  8:37 kazu at cs dot umass dot edu
  2004-05-06 12:48 ` [Bug optimization/15310] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-06  8:37 UTC (permalink / raw)
  To: gcc-bugs

Optimize an addition in a bit field.

struct {
   unsigned int bit0:1;
   unsigned int ubyte:31;
} sdata;

void foo()
{
  sdata.ubyte++;
}

This testcase is inspired by

http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00058.html

Currently, I get:

foo:
        movl    sdata, %eax
        movl    %eax, %edx
        shrl    %edx
        leal    2(%edx,%edx), %edx
        andl    $1, %eax
        orl     %edx, %eax
        movl    %eax, sdata
        ret

We should be able to get

foo:
        addl    $2, sdata
        ret

We might want to lower bit field manipulation at tree level.

-- 
           Summary: [tree-ssa] Optimize an addition in a bit field
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: enhancement
          Priority: P2
         Component: optimization
        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,roger at eyesopen dot
                    com


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


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

* [Bug optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
@ 2004-05-06 12:48 ` pinskia at gcc dot gnu dot org
  2004-05-16 11:29 ` [Bug tree-optimization/15310] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-06 12:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-06 12:48 -------
Confirmed.
And this should also be optimizated:
struct {
   unsigned int bit0:1;
   unsigned int ubyte:31;
} sdata;
void foo1()
{
  unsigned int i = sdata.ubyte;
  unsigned int i1 = i+1;
  sdata.ubyte = i1;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-06 12:48:01
               date|                            |
   Target Milestone|---                         |tree-ssa


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


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

* [Bug tree-optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
  2004-05-06 12:48 ` [Bug optimization/15310] " pinskia at gcc dot gnu dot org
@ 2004-05-16 11:29 ` pinskia at gcc dot gnu dot org
  2004-05-31 13:18 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-16 11:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-15 12:27 -------
This could be fixed with a tree combiner.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |15459


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


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

* [Bug tree-optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
  2004-05-06 12:48 ` [Bug optimization/15310] " pinskia at gcc dot gnu dot org
  2004-05-16 11:29 ` [Bug tree-optimization/15310] " pinskia at gcc dot gnu dot org
@ 2004-05-31 13:18 ` pinskia at gcc dot gnu dot org
  2004-06-30 10:25 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-31 13:18 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.5.0                       |---


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


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

* [Bug tree-optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-05-31 13:18 ` pinskia at gcc dot gnu dot org
@ 2004-06-30 10:25 ` cvs-commit at gcc dot gnu dot org
  2004-06-30 22:21 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-30 10:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-30 10:10 -------
Subject: Bug 15310

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jakub@gcc.gnu.org	2004-06-30 10:09:55

Modified files:
	gcc            : ChangeLog simplify-rtx.c expr.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20040629-1.c 

Log message:
	* simplify-rtx.c (simplify_binary_operation): Simplify
	((A & N) + B) & M -> (A + B) & M if M is pow2 minus 1 constant and
	N has at least all bits in M set as well.
	
	PR tree-optimization/15310
	* expr.c (expand_assignment): Optimize += or -= on a bit field in
	most significant bits.
	
	* gcc.c-torture/execute/20040629-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4205&r2=2.4206
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/simplify-rtx.c.diff?cvsroot=gcc&r1=1.194&r2=1.195
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.657&r2=1.658
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3919&r2=1.3920
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040629-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug tree-optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-06-30 10:25 ` cvs-commit at gcc dot gnu dot org
@ 2004-06-30 22:21 ` pinskia at gcc dot gnu dot org
  2004-07-10  0:30 ` pinskia at gcc dot gnu dot org
  2004-08-16 16:42 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-30 22:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-30 22:17 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug tree-optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-06-30 22:21 ` pinskia at gcc dot gnu dot org
@ 2004-07-10  0:30 ` pinskia at gcc dot gnu dot org
  2004-08-16 16:42 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-10  0:30 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |3.5.0


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


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

* [Bug tree-optimization/15310] [tree-ssa] Optimize an addition in a bit field
  2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2004-07-10  0:30 ` pinskia at gcc dot gnu dot org
@ 2004-08-16 16:42 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-16 16:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-16 16:42 -------
Subject: Bug 15310

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-rhl-branch
Changes by:	jakub@gcc.gnu.org	2004-08-16 16:42:16

Modified files:
	gcc            : ChangeLog expr.c simplify-rtx.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20040629-1.c 20040705-1.c 
	                                     20040705-2.c 20040709-1.c 
	                                     20040709-2.c 

Log message:
	2004-07-09  Jakub Jelinek  <jakub@redhat.com>
	
	* expr.c (expand_assignment): Reenable bitfield += optimizations.
	Use alias set 0 for memory, do proper mode calculations and adjust
	address for memories.
	
	* gcc.c-torture/execute/20040709-1.c: New test.
	* gcc.c-torture/execute/20040709-2.c: New test.
	
	2004-07-05  Jakub Jelinek  <jakub@redhat.com>
	
	* expr.c (expand_assignment): Disable the bitfield += optimizations.
	
	* gcc.c-torture/execute/20040629-1.c (FIELDS1, FIELDS2): Define to
	nothing if not yet defined.  Use it in b, c and d type definitions.
	* gcc.c-torture/execute/20040705-1.c: New test.
	* gcc.c-torture/execute/20040705-2.c: New test.
	
	2004-07-01  Jakub Jelinek  <jakub@redhat.com>
	
	* expr.c (expand_assignment): Optimize bitfld += cst for 1 bit
	bitfields as well.  STRIP_NOPS from src operand and PLUS_EXPR's
	first operand.  Don't optimize if the bitfield is volatile.
	
	2004-06-29  Jakub Jelinek  <jakub@redhat.com>
	
	* simplify-rtx.c (simplify_binary_operation): Simplify
	((A & N) + B) & M -> (A + B) & M if M is pow2 minus 1 constant and
	N has at least all bits in M set as well.
	
	PR tree-optimization/15310
	* expr.c (expand_assignment): Optimize += or -= on a bit field in
	most significant bits.
	
	* gcc.c-torture/execute/20040629-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=2.2326.2.399.2.26&r2=2.2326.2.399.2.27
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=1.615.4.11.2.2&r2=1.615.4.11.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/simplify-rtx.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=1.172.4.1.2.1&r2=1.172.4.1.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=1.3389.2.170.2.13&r2=1.3389.2.170.2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040629-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=NONE&r2=1.2.14.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040705-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=NONE&r2=1.1.14.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040705-2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=NONE&r2=1.1.14.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040709-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=NONE&r2=1.1.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040709-2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=NONE&r2=1.1.12.1



-- 


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


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

end of thread, other threads:[~2004-08-16 16:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-06  8:37 [Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field kazu at cs dot umass dot edu
2004-05-06 12:48 ` [Bug optimization/15310] " pinskia at gcc dot gnu dot org
2004-05-16 11:29 ` [Bug tree-optimization/15310] " pinskia at gcc dot gnu dot org
2004-05-31 13:18 ` pinskia at gcc dot gnu dot org
2004-06-30 10:25 ` cvs-commit at gcc dot gnu dot org
2004-06-30 22:21 ` pinskia at gcc dot gnu dot org
2004-07-10  0:30 ` pinskia at gcc dot gnu dot org
2004-08-16 16:42 ` cvs-commit 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).