public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15349] New: [tree-ssa] Merge two phi nodes.
@ 2004-05-09 19:48 kazu at cs dot umass dot edu
  2004-05-09 20:36 ` [Bug optimization/15349] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 19:48 UTC (permalink / raw)
  To: gcc-bugs

void bar (void);

int
foo (int a, int b)
{
  int t;

  if (b)
    {
      if (a)
	t = 3;
      else
	t = 5;

      if (t)
	a++;
    }
  else
    t = 7;

  return t - 1;
}

I get:

foo (a, b)
{
  int t;

<bb 0>:
  if (b_3 != 0) goto <L0>; else goto <L7>;

<L0>:;
  if (a_6 != 0) goto <L1>; else goto <L3>;

<L1>:;

  # t_1 = PHI <5(1), 3(2)>;
<L3>:;

  # t_2 = PHI <7(0), t_1(3)>;
<L7>:;
  return t_2 - 1;

}

Note that we can merge the first PHI into the second one like so:

  # t_2 = PHI <7(0), 5(1), 3(2)>;

by replacing goto <L1>; with goto <L7>;

Note that this optimization is pretty important because I see alias.c
containing the following:

<L191>:;

  # iftmp.1496_89 = PHI <0(139), 1(138)>;
<L192>:;
  iftmp.1493_304 = iftmp.1496_89 != 0;

  # iftmp.1493_88 = PHI <iftmp.1493_304(140), iftmp.1493_316(136)>;
<L193>:;
  if (iftmp.1493_88) goto <L194>; else goto <L202>;

Once PR 14797 is solved, the above code should become something like

<L191>:;

  # iftmp.1493_304 = PHI <0(139), 1(138)>;
<L192>:;

  # iftmp.1493_88 = PHI <iftmp.1493_304(140), iftmp.1493_316(136)>;
<L193>:;
  if (iftmp.1493_88) goto <L194>; else goto <L202>;

Once this PR is solved, we would have

<L192>:;

  # iftmp.1493_88 = PHI <0(139), 1(138), iftmp.1493_316(136)>;
<L193>:;
  if (iftmp.1493_88) goto <L194>; else goto <L202>;

Now it's trivial to redirect jumps from bb 139 and bb 138
to <L202> and <L194>, respectively, provided that nobody else
uses iftmp.1493_88.

-- 
           Summary: [tree-ssa] Merge two phi nodes.
           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=15349


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

end of thread, other threads:[~2005-01-20 21:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-09 19:48 [Bug optimization/15349] New: [tree-ssa] Merge two phi nodes kazu at cs dot umass dot edu
2004-05-09 20:36 ` [Bug optimization/15349] " pinskia at gcc dot gnu dot org
2004-05-21 13:32 ` [Bug tree-optimization/15349] " dnovillo at gcc dot gnu dot org
2004-05-25  0:11 ` pinskia at gcc dot gnu dot org
2004-09-14  2:55 ` pinskia at gcc dot gnu dot org
2004-09-14  3:53 ` kazu at cs dot umass dot edu
2004-09-19 19:03 ` kazu at cs dot umass dot edu
2004-09-20 20:08 ` kazu at cs dot umass dot edu
2004-12-22  4:59 ` kazu at cs dot umass dot edu
2005-01-20 19:21 ` cvs-commit at gcc dot gnu dot org
2005-01-20 19:49 ` kazu at cs dot umass dot edu
2005-01-20 21:10 ` pinskia at gcc dot gnu dot 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).