public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c
@ 2005-04-18  3:06 pinskia at gcc dot gnu dot org
  2005-04-18  3:06 ` [Bug middle-end/21082] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18  3:06 UTC (permalink / raw)
  To: gcc-bugs

The following C++ code is not fully as optimizated as the C version:
typedef __SIZE_TYPE__ size_t;
size_t a[100];
size_t f(size_t b, size_t c)
{
  return &a[b] - &a[c];
}

Found this while looking into the tree dump for mgrid.

-- 
           Summary: &a[b] - &a[c] is not folded to b - c
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
@ 2005-04-18  3:06 ` pinskia at gcc dot gnu dot org
  2005-04-18  3:20 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18  3:06 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |19987
              nThis|                            |


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
  2005-04-18  3:06 ` [Bug middle-end/21082] " pinskia at gcc dot gnu dot org
@ 2005-04-18  3:20 ` pinskia at gcc dot gnu dot org
  2005-04-18  4:06 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18  3:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-18 03:19 -------
This should improve mgrid and IV selection.

-- 


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
  2005-04-18  3:06 ` [Bug middle-end/21082] " pinskia at gcc dot gnu dot org
  2005-04-18  3:20 ` pinskia at gcc dot gnu dot org
@ 2005-04-18  4:06 ` pinskia at gcc dot gnu dot org
  2005-04-19 14:58 ` phython at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18  4:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-18 04:06 -------
The code in comment #0 should produce no multiply/divides/shifts but does currently (again with the 
C++ front-end).
Take the following code:
typedef __SIZE_TYPE__ size_t;
size_t a[100];
size_t f(size_t b, size_t c)
{
  return (&a[b] - &a[c])*sizeof(*a);
}
We get the good code but only after combine so this blocks both the generic one and the RTL based 
missed fold optimizators and we can add the TREE keyword too for the above testcase.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |19986
              nThis|                            |
           Keywords|                            |TREE


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-04-18  4:06 ` pinskia at gcc dot gnu dot org
@ 2005-04-19 14:58 ` phython at gcc dot gnu dot org
  2005-04-23 14:31 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: phython at gcc dot gnu dot org @ 2005-04-19 14:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From phython at gcc dot gnu dot org  2005-04-19 14:57 -------
 Yup, the dumps from the c++ front end is:
;; Function size_t f(size_t, size_t) (_Z1fjj)

size_t f(size_t, size_t) (b, c)
{
<bb 0>:
  return (size_t) (((int) &a[b] - (int) &a[c]) /[ex] 4);

}

 and the C front-end dump is:
;; Function f (f)

f (b, c)
{
<bb 0>:
  return (size_t) (b - c);

}


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-19 14:57:39
               date|                            |


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-04-19 14:58 ` phython at gcc dot gnu dot org
@ 2005-04-23 14:31 ` rguenth at gcc dot gnu dot org
  2005-04-23 16:24 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-04-23 14:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-04-23 14:31 -------
PR19807 is related.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |19807
              nThis|                            |


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-04-23 14:31 ` rguenth at gcc dot gnu dot org
@ 2005-04-23 16:24 ` pinskia at gcc dot gnu dot org
  2005-04-23 21:05 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-23 16:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-23 16:24 -------
Zdenek was complaining about this in:
 <http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02411.html>.

-- 


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-04-23 16:24 ` pinskia at gcc dot gnu dot org
@ 2005-04-23 21:05 ` rguenth at gcc dot gnu dot org
  2005-04-23 21:34 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-04-23 21:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-04-23 21:05 -------
Patch at
http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02499.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |04/msg02499.html
             Status|NEW                         |ASSIGNED
           Keywords|                            |patch
   Last reconfirmed|2005-04-19 14:57:39         |2005-04-23 21:05:50
               date|                            |


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2005-04-23 21:05 ` rguenth at gcc dot gnu dot org
@ 2005-04-23 21:34 ` cvs-commit at gcc dot gnu dot org
  2005-04-23 21:36 ` rguenth at gcc dot gnu dot org
  2005-04-23 21:37 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-04-23 21:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-04-23 21:34 -------
Subject: Bug 21082

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rguenth@gcc.gnu.org	2005-04-23 21:34:42

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/tree-ssa: pr21082.C 

Log message:
	2005-04-23  Richard Guenther  <rguenth@gcc.gnu.org>
	
	PR middle-end/21082
	* fold-const.c: Fold &a[i]-&a[j] to i-j.
	
	* g++.dg/tree-ssa/pr21082.C: New testcase.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8430&r2=2.8431
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.569&r2=1.570
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5388&r2=1.5389
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/tree-ssa/pr21082.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2005-04-23 21:34 ` cvs-commit at gcc dot gnu dot org
@ 2005-04-23 21:36 ` rguenth at gcc dot gnu dot org
  2005-04-23 21:37 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-04-23 21:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-04-23 21:36 -------
Fixed.

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


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


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

* [Bug middle-end/21082] &a[b] - &a[c] is not folded to b - c
  2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2005-04-23 21:36 ` rguenth at gcc dot gnu dot org
@ 2005-04-23 21:37 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-23 21:37 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2005-04-23 21:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-18  3:06 [Bug middle-end/21082] New: &a[b] - &a[c] is not folded to b - c pinskia at gcc dot gnu dot org
2005-04-18  3:06 ` [Bug middle-end/21082] " pinskia at gcc dot gnu dot org
2005-04-18  3:20 ` pinskia at gcc dot gnu dot org
2005-04-18  4:06 ` pinskia at gcc dot gnu dot org
2005-04-19 14:58 ` phython at gcc dot gnu dot org
2005-04-23 14:31 ` rguenth at gcc dot gnu dot org
2005-04-23 16:24 ` pinskia at gcc dot gnu dot org
2005-04-23 21:05 ` rguenth at gcc dot gnu dot org
2005-04-23 21:34 ` cvs-commit at gcc dot gnu dot org
2005-04-23 21:36 ` rguenth at gcc dot gnu dot org
2005-04-23 21:37 ` 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).