public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/31981]  New: Missed forw prop with indirect ref and addr.
@ 2007-05-17 22:49 pinskia at gcc dot gnu dot org
  2007-05-17 22:49 ` [Bug tree-optimization/31981] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-17 22:49 UTC (permalink / raw)
  To: gcc-bugs

This testcase should pass:
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-forwprop" }  */

/* We should be able to optimize this to b.t[i] = 1 during
   early optimizations.  */

struct a
{
  int t[10];
};

struct a b;

void f(__SIZE_TYPE__ i)
{
  int *c = b.t;
  c[i] = 1;
}

/* { dg-final { scan-tree-dump "t\\\[i.*\\\] = 1;" "forwprop1" { xfail *-*-* }
} } */
/* { dg-final { scan-tree-dump "t\\\[i.*\\\] = 1;" "forwprop2" } } */
/* { dg-final { cleanup-tree-dump "forwprop?" } } */

---------

I found this while fixing up forwprop for the pointer plus branch.


-- 
           Summary: Missed forw prop with indirect ref and addr.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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


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

* [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr.
  2007-05-17 22:49 [Bug tree-optimization/31981] New: Missed forw prop with indirect ref and addr pinskia at gcc dot gnu dot org
@ 2007-05-17 22:49 ` pinskia at gcc dot gnu dot org
  2007-05-24  9:54 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-17 22:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


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

* [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr.
  2007-05-17 22:49 [Bug tree-optimization/31981] New: Missed forw prop with indirect ref and addr pinskia at gcc dot gnu dot org
  2007-05-17 22:49 ` [Bug tree-optimization/31981] " pinskia at gcc dot gnu dot org
@ 2007-05-24  9:54 ` rguenth at gcc dot gnu dot org
  2007-05-24 10:09 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-05-24  9:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-05-24 10:54 -------
is this fixed on pointer_plus branch?  Confirmed on the mainline.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-05-24 10:54:13
               date|                            |


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


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

* [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr.
  2007-05-17 22:49 [Bug tree-optimization/31981] New: Missed forw prop with indirect ref and addr pinskia at gcc dot gnu dot org
  2007-05-17 22:49 ` [Bug tree-optimization/31981] " pinskia at gcc dot gnu dot org
  2007-05-24  9:54 ` rguenth at gcc dot gnu dot org
@ 2007-05-24 10:09 ` rguenth at gcc dot gnu dot org
  2007-05-25 10:22 ` [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr. due to CCP rguenth at gcc dot gnu dot org
  2007-07-01  1:22 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-05-24 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-05-24 11:09 -------
Actually this is just a tree-combining issue.  CCP already transforms this to

  c_1 = &b.t[0];
  D.2000_3 = i_2(D) * 4;
  D.2001_4 = (int *) D.2000_3;
  D.2002_5 = D.2001_4 + &b.t[0];
  *D.2002_5 = 1;

not combining D.2001_4 + &b.t[0].  There is nothing forwprop can do about this
with the existing framework, but of course it can be extended to propagate
OFFSET + &OBJ.  Easier to do this after the pointer_plus merge.


-- 


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


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

* [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr. due to CCP
  2007-05-17 22:49 [Bug tree-optimization/31981] New: Missed forw prop with indirect ref and addr pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-05-24 10:09 ` rguenth at gcc dot gnu dot org
@ 2007-05-25 10:22 ` rguenth at gcc dot gnu dot org
  2007-07-01  1:22 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-05-25 10:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2007-05-25 11:21 -------
Indeed with -fno-tree-ccp the testcase is optimized by forwprop1 to

<bb 2>:
  D.2000_3 = i_2(D) * 4;
  D.2001_4 = (int *) D.2000_3;
  D.2002_5 = &b.t[i_2(D)];
  *D.2002_5 = 1;
  return;

and then by forwprop2 to

<bb 2>:
  D.2002_5 = &b.t[i_2(D)];
  b.t[i_2(D)] = 1;
  return;

so the right fix is to eventually teach CCP to do the first transformation,
or rather teach fold_stmt to do a little tree combining in this case.  Ugh.
Or avoid this particular type of CCP.  Ugh.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Missed forw prop with       |Missed forw prop with
                   |indirect ref and addr.      |indirect ref and addr. due
                   |                            |to CCP


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


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

* [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr. due to CCP
  2007-05-17 22:49 [Bug tree-optimization/31981] New: Missed forw prop with indirect ref and addr pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-05-25 10:22 ` [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr. due to CCP rguenth at gcc dot gnu dot org
@ 2007-07-01  1:22 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-01  1:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-07-01 01:22 -------
> OFFSET + &OBJ.

Well pointer plus was merged so it is always &OBJ + OFFSET :).


-- 


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


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

* [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr. due to CCP
       [not found] <bug-31981-4@http.gcc.gnu.org/bugzilla/>
@ 2011-04-14 19:04 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-04-14 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.0

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-04-14 19:04:46 UTC ---
Fixed in 4.5.0 and above.


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

end of thread, other threads:[~2011-04-14 19:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-17 22:49 [Bug tree-optimization/31981] New: Missed forw prop with indirect ref and addr pinskia at gcc dot gnu dot org
2007-05-17 22:49 ` [Bug tree-optimization/31981] " pinskia at gcc dot gnu dot org
2007-05-24  9:54 ` rguenth at gcc dot gnu dot org
2007-05-24 10:09 ` rguenth at gcc dot gnu dot org
2007-05-25 10:22 ` [Bug tree-optimization/31981] Missed forw prop with indirect ref and addr. due to CCP rguenth at gcc dot gnu dot org
2007-07-01  1:22 ` pinskia at gcc dot gnu dot org
     [not found] <bug-31981-4@http.gcc.gnu.org/bugzilla/>
2011-04-14 19:04 ` pinskia at gcc dot gnu.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).