public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/18046] New: Missed jump threading optimization
@ 2004-10-18 12:16 steven at gcc dot gnu dot org
  2004-10-18 12:52 ` [Bug tree-optimization/18046] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-10-18 12:16 UTC (permalink / raw)
  To: gcc-bugs

Filed under unknown since there is no version tag for the
tree-cleanup-branch.
The problem probably also exists on mainline, but I have
not tried it there.

Consider this code,

-----------------------------------------------------
extern void foo (void);
extern int i;
void
bar (void)
{
  switch (i)
    {
    case 0:
      foo ();
      break;
    case 1:
      break;
    }
                                                                               
                
  switch (i)
    {
    case 0:
      foo ();
      break;
    case 1:
      break;
    }
}
-----------------------------------------------------

This gives the following .dse2 dump:

;; Function bar (bar)
                                                                               
                
bar ()
{
  int i.0;
                                                                               
                
<bb 0>:
  #   VUSE <i_2>;
  i.0_3 = i;
  switch (i.0_3)
    {
      case 0: goto <L0>;
      default : goto <L1>;
    }
                                                                               
                
<L0>:;
  #   i_6 = V_MAY_DEF <i_2>;
  foo ();
                                                                               
                
  # i_1 = PHI <i_2(0), i_6(1)>;
<L1>:;
  #   VUSE <i_1>;
  i.0_4 = i;
  switch (i.0_4)
    {
      case 0: goto <L4>;
      default : goto <L5>;
    }
                                                                               
                
<L4>:;
  #   i_5 = V_MAY_DEF <i_1>;
  foo ();
                                                                               
                
<L5>:;
  return;
                                                                               
                
}

If the first switch goes through the default case, the
switch condition "i" is not call clobbered by the call
to "foo ()" so in the second switch "i" is unchanged and
we can thread the jump.

We don't catch this jump threading opportunity on trees,
but we *do* catch it on RTL.  This is *the* major source
of missed jump threads on the tree-cleanup-branch (we
catch rougly a thousand of these on the cc1-i file set).

If we teach the tree optimizers to catch this case, we
can almost certainly kill the RTL thread_jump junk on the
tree-cleanup-branch.

-- 
           Summary: Missed jump threading optimization
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization, alias, TREE
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steven at gcc dot gnu dot org
                CC: dnovillo at redhat dot com,gcc-bugs at gcc dot gnu dot
                    org


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


^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <bug-18046-280@http.gcc.gnu.org/bugzilla/>]
[parent not found: <bug-18046-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-11-08 22:30 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-18 12:16 [Bug tree-optimization/18046] New: Missed jump threading optimization steven at gcc dot gnu dot org
2004-10-18 12:52 ` [Bug tree-optimization/18046] " pinskia at gcc dot gnu dot org
2004-10-18 13:22 ` steven at gcc dot gnu dot org
2004-10-18 17:30 ` steven at gcc dot gnu dot org
2004-10-18 18:31 ` law at redhat dot com
2004-10-18 22:50 ` stevenb at suse dot de
2004-10-19 20:16 ` law at redhat dot com
2005-04-23 16:58 ` steven at gcc dot gnu dot org
     [not found] <bug-18046-280@http.gcc.gnu.org/bugzilla/>
2005-10-07 21:21 ` steven at gcc dot gnu dot org
2006-03-21 15:57 ` law at redhat dot com
2006-03-21 16:05 ` pinskia at gcc dot gnu dot org
2006-03-21 16:57 ` dberlin at dberlin dot org
2008-09-21 14:00 ` steven at gcc dot gnu dot org
2008-09-23 21:56 ` law at redhat dot com
2010-02-04 22:52 ` steven at gcc dot gnu dot org
2010-07-13 10:30 ` steven at gcc dot gnu dot org
     [not found] <bug-18046-4@http.gcc.gnu.org/bugzilla/>
2011-07-20  0:34 ` pinskia at gcc dot gnu.org
2012-11-08 22:30 ` steven 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).