public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level
@ 2004-03-25  6:51 pinskia at gcc dot gnu dot org
  2004-03-25  6:51 ` [Bug optimization/14731] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-25  6:51 UTC (permalink / raw)
  To: gcc-bugs

Some more missed jump threading on the tree level.
#ifdef __cplusplus
#define _Bool bool
#endif

int link_error(void);
int s(void);

int t(int i)
{
  _Bool g = i == 4;
 int h = g;
 _Bool j = h;
 int k = j;
 _Bool l = k == 0;
 _Bool o = !l;
 int m = o;

 if (m)
  if (i != 4)
   return link_error();
 return 0;
}

-- 
           Summary: [tree-ssa] missed jump threading on the tree level
           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: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,law at gcc dot gnu dot
                    org


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


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

* [Bug optimization/14731] [tree-ssa] missed jump threading on the tree level
  2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
@ 2004-03-25  6:51 ` pinskia at gcc dot gnu dot org
  2004-03-28  7:35 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-25  6:51 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |tree-ssa


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


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

* [Bug optimization/14731] [tree-ssa] missed jump threading on the tree level
  2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
  2004-03-25  6:51 ` [Bug optimization/14731] " pinskia at gcc dot gnu dot org
@ 2004-03-28  7:35 ` pinskia at gcc dot gnu dot org
  2004-03-30 20:23 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-28  7:35 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |14758


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


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

* [Bug optimization/14731] [tree-ssa] missed jump threading on the tree level
  2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
  2004-03-25  6:51 ` [Bug optimization/14731] " pinskia at gcc dot gnu dot org
  2004-03-28  7:35 ` pinskia at gcc dot gnu dot org
@ 2004-03-30 20:23 ` pinskia at gcc dot gnu dot org
  2004-03-30 20:27 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-30 20:23 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |14758
              nThis|                            |
  BugsThisDependsOn|14758                       |


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


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

* [Bug optimization/14731] [tree-ssa] missed jump threading on the tree level
  2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-03-30 20:23 ` pinskia at gcc dot gnu dot org
@ 2004-03-30 20:27 ` pinskia at gcc dot gnu dot org
  2004-03-31  5:36 ` pinskia at gcc dot gnu dot org
  2004-05-04 20:59 ` law at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-30 20:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-30 20:27 -------
Confirmed, I am taking care of this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-30 20:27:45
               date|                            |


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


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

* [Bug optimization/14731] [tree-ssa] missed jump threading on the tree level
  2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-03-30 20:27 ` pinskia at gcc dot gnu dot org
@ 2004-03-31  5:36 ` pinskia at gcc dot gnu dot org
  2004-05-04 20:59 ` law at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-31  5:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-31 05:36 -------
Actually this is all caused by the same problems which PR 14758 refereces so closing as 
a dup.

*** This bug has been marked as a duplicate of 14758 ***

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


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


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

* [Bug optimization/14731] [tree-ssa] missed jump threading on the tree level
  2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-03-31  5:36 ` pinskia at gcc dot gnu dot org
@ 2004-05-04 20:59 ` law at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: law at redhat dot com @ 2004-05-04 20:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2004-05-04 20:59 -------
Subject: Re:  New: [tree-ssa] missed jump threading on 
 the tree level

In message <20040325065108.14731.pinskia@gcc.gnu.org>, "pinskia at gcc dot gnu 
dot org" writes:
 >Some more missed jump threading on the tree level.
 >#ifdef __cplusplus
 >#define _Bool bool
 >#endif
 >
 >int link_error(void);
 >int s(void);
 >
 >int t(int i)
 >{
 >  _Bool g = i == 4;
 > int h = g;
 > _Bool j = h;
 > int k = j;
 > _Bool l = k == 0;
 > _Bool o = !l;
 > int m = o;
 >
 > if (m)
 >  if (i != 4)
 >   return link_error();
 > return 0;
 >}
Yes.  The easiest way I see to deal with this is to have the forward
propagation code handle cascading opportunities to forward propagate
single use variables.

That turns out to be rather easy by having two worklists (one for 
statements to reexamine, one for variables which we may be able to
propagate).  We iterate until the worklists are empty.


So before the single use variable propagation phase we have something
like this:


  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru)
  g_1 = i_5 == 4;
  j_2 = g_1 != 0;
  l_3 = j_2 == 0;
  o_4 = l_3 == 0;
  if (o_4 != 0) goto <L12>; else goto <L14>;
  # SUCC: 3 [50.0%]  (false) 1 [50.0%]  (true)

  # BLOCK 1
  # PRED: 0 [50.0%]  (true)
<L12>:;
  if (i_5 != 4) goto <L13>; else goto <L14>;
  # SUCC: 3 [31.9%]  (false) 2 [68.0%]  (true)
  [ ... ]


After forward propagation we have:
  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru)
  if (i_5 == 4) goto <L12>; else goto <L14>;
  # SUCC: 3 [50.0%]  (false) 1 [50.0%]  (true)
  
  # BLOCK 1 
  # PRED: 0 [50.0%]  (true) 
<L12>:;
  if (i_5 != 4) goto <L13>; else goto <L14>;
  # SUCC: 3 [31.9%]  (false) 2 [68.0%]  (true)
  [ ... ]


Which DOM then turns into:

  # BLOCK 0 
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  return 0;
  # SUCC: EXIT [100.0%] 


Which looks like what we want :-)

jeff



-- 


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


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

end of thread, other threads:[~2004-05-04 20:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-25  6:51 [Bug optimization/14731] New: [tree-ssa] missed jump threading on the tree level pinskia at gcc dot gnu dot org
2004-03-25  6:51 ` [Bug optimization/14731] " pinskia at gcc dot gnu dot org
2004-03-28  7:35 ` pinskia at gcc dot gnu dot org
2004-03-30 20:23 ` pinskia at gcc dot gnu dot org
2004-03-30 20:27 ` pinskia at gcc dot gnu dot org
2004-03-31  5:36 ` pinskia at gcc dot gnu dot org
2004-05-04 20:59 ` law at redhat dot com

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