public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15352] New: [tree-ssa]
@ 2004-05-09 19:59 kazu at cs dot umass dot edu
  2004-05-09 20:00 ` [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit kazu at cs dot umass dot edu
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 19:59 UTC (permalink / raw)
  To: gcc-bugs

int
foo (int a, int b, int c)
{
  if (a == 1 || b == 2)
    {
      if (a == 1 || c == 3)
	f1 ();
      else
	f2 ();
    }
}

I get:

foo (a, b, c)
{
  _Bool T.4;
  _Bool T.3;
  _Bool T.2;
  _Bool T.1;
  _Bool T.0;

<bb 0>:
  T.0_2 = a_1 == 1;
  T.1_4 = b_3 == 2;
  T.2_5 = T.0_2 || T.1_4;
  if (T.2_5) goto <L0>; else goto <L3>;

<L0>:;
  T.3_8 = c_7 == 3;
  T.4_9 = T.0_2 || T.3_8;
  if (T.4_9) goto <L1>; else goto <L2>;

<L1>:;
  f1 () [tail call];
  goto <bb 4> (<L3>);

<L2>:;
  f2 () [tail call];

<L3>:;
  return;

}

Note that a jump threading opportunity of T.0_2 is missed.
Ideally, we should get something like:

bar (a, b, c)
{
<bb 0>:
  if (a_1 != 1) goto <L0>; else goto <L6>;

<L0>:;
  if (b_3 != 2) goto <L1>; else goto <L4>;

<L1>:;
  return;

<L4>:;
  if (c_2 != 3) goto <L5>; else goto <L6>;

<L5>:;
  f2 () [tail call];
  return;

<L6>:;
  f1 () [tail call];
  return;

}

We should probably prefer short circuit to reduce the number of temporaries
during SSA optimizations to get full exposure to jump threading.
We "un-short-circuit" later as needed.

-- 
           Summary: [tree-ssa]
           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


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


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

* [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
@ 2004-05-09 20:00 ` kazu at cs dot umass dot edu
  2004-05-09 20:51 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 20:00 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[tree-ssa]                  |[tree-ssa] missed jump
                   |                            |threading opportunity due to
                   |                            |lack of short circuit


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


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

* [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
  2004-05-09 20:00 ` [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit kazu at cs dot umass dot edu
@ 2004-05-09 20:51 ` pinskia at gcc dot gnu dot org
  2004-05-09 22:11 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-09 20:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-09 20:51 -------
Confirmed.  I am going try to do some of this, at least the combining back.

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


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


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

* [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
  2004-05-09 20:00 ` [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit kazu at cs dot umass dot edu
  2004-05-09 20:51 ` pinskia at gcc dot gnu dot org
@ 2004-05-09 22:11 ` pinskia at gcc dot gnu dot org
  2004-05-13 23:50 ` [Bug tree-optimization/15352] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-09 22:11 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |15357


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


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

* [Bug tree-optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-05-09 22:11 ` pinskia at gcc dot gnu dot org
@ 2004-05-13 23:50 ` pinskia at gcc dot gnu dot org
  2004-05-24 22:23 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-13 23:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-13 13:34 -------
Mine.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug tree-optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-05-13 23:50 ` [Bug tree-optimization/15352] " pinskia at gcc dot gnu dot org
@ 2004-05-24 22:23 ` pinskia at gcc dot gnu dot org
  2005-02-14 22:38 ` law at redhat dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 22:23 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

* [Bug tree-optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-05-24 22:23 ` pinskia at gcc dot gnu dot org
@ 2005-02-14 22:38 ` law at redhat dot com
  2005-02-15  0:32 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: law at redhat dot com @ 2005-02-14 22:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2005-02-14 20:01 -------
The new jump thread selection code handles this properly.

I will note that your comments about the code we ought to be able to generate
are wrong.  The correctly optimized code should look like this:  (note the
difference in where we test c == 3.


foo (a, b, c)
{
  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  if (a_1 == 1) goto <L3>; else goto <L0>;
  # SUCC: 3 [14.9%]  (true,exec) 1 [85.1%]  (false,exec)

  # BLOCK 1
  # PRED: 0 [85.1%]  (false,exec)
<L0>:;
  if (b_3 == 2) goto <L2>; else goto <L5>;
  # SUCC: 2 [45.3%]  (true,exec) 5 [54.7%]  (false,exec)

  # BLOCK 2
  # PRED: 1 [45.3%]  (true,exec)
<L2>:;
  if (c_2 == 3) goto <L3>; else goto <L4>;
  # SUCC: 3 [48.8%]  (true,exec) 4 [51.2%]  (false,exec)

  # BLOCK 3
  # PRED: 0 [14.9%]  (true,exec) 2 [48.8%]  (true,exec)
<L3>:;
  f1 ();
  goto <bb 5> (<L5>);
  # SUCC: 5 [100.0%]  (fallthru,exec)

  # BLOCK 4
  # PRED: 2 [51.2%]  (false,exec)
<L4>:;
  f2 ();
  # SUCC: 5 [100.0%]  (fallthru,exec)

  # BLOCK 5
  # PRED: 1 [54.7%]  (false,exec) 3 [100.0%]  (fallthru,exec) 4 [100.0%] 
(fallthru,exec)
<L5>:;
  return;


-- 


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


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

* [Bug tree-optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2005-02-14 22:38 ` law at redhat dot com
@ 2005-02-15  0:32 ` pinskia at gcc dot gnu dot org
  2005-04-23  0:56 ` law at redhat dot com
  2005-04-25  4:58 ` law at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-15  0:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-14 20:14 -------
This is very closely related to PR 18832.

-- 


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


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

* [Bug tree-optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
                   ` (6 preceding siblings ...)
  2005-02-15  0:32 ` pinskia at gcc dot gnu dot org
@ 2005-04-23  0:56 ` law at redhat dot com
  2005-04-25  4:58 ` law at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: law at redhat dot com @ 2005-04-23  0:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2005-04-23 00:55 -------
Should be fixed with today's checkin -- with the caveat that Kazu's
desired code is incorrect.  We thread everything fully in this code now.


-- 


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


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

* [Bug tree-optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit
  2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
                   ` (7 preceding siblings ...)
  2005-04-23  0:56 ` law at redhat dot com
@ 2005-04-25  4:58 ` law at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: law at redhat dot com @ 2005-04-25  4:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2005-04-25 04:58 -------
Fixed by:
http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02426.html


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |04/msg02426.html
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2005-04-25  4:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-09 19:59 [Bug optimization/15352] New: [tree-ssa] kazu at cs dot umass dot edu
2004-05-09 20:00 ` [Bug optimization/15352] [tree-ssa] missed jump threading opportunity due to lack of short circuit kazu at cs dot umass dot edu
2004-05-09 20:51 ` pinskia at gcc dot gnu dot org
2004-05-09 22:11 ` pinskia at gcc dot gnu dot org
2004-05-13 23:50 ` [Bug tree-optimization/15352] " pinskia at gcc dot gnu dot org
2004-05-24 22:23 ` pinskia at gcc dot gnu dot org
2005-02-14 22:38 ` law at redhat dot com
2005-02-15  0:32 ` pinskia at gcc dot gnu dot org
2005-04-23  0:56 ` law at redhat dot com
2005-04-25  4:58 ` 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).