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

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