This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/18133] computed gotos are not folded back to regular gotos when it is found that they are not computed gotos at all


------- Additional Comments From kazu at cs dot umass dot edu  2005-01-23 20:39 -------
IMHO, we need to call rewrite_ssa_into_ssa after fixing CFG.

Consider:

int c, d;

int
bar (int a)
{
  void *p;
  int b;

  if (a!=0)
    {
      b = 3;
      p = &&L0;
    }
  else
    {
      b = 5;
      p = &&L1;
    }

  goto *p;

 L0:
  c = b;
  return 1;

 L1:
  d = b;
  return 0;
}

Here is the corresponding SSA form.

<bb 0>:
  if (a_4 != 0) goto <L2>; else goto <L7>;

<L7>:;

  # p_2 = PHI <&L0(0), &L1(1)>;
  # b_1 = PHI <3(0), 5(1)>;
<L2>:;
  goto p_2;

L0:;
  c = b_1;
  goto <bb 5> (<L5>);

L1:;
  d = b_1;

  # D.1130_3 = PHI <1(3), 0(4)>;
<L5>:;
  return D.1130_3;

Then the problem becomes pretty much the same as jump threading.
Note that <L2> has two incoming edges, one from <bb 0> and the other from
<L7>.  We are basically trying to thread each incoming edge through <L2>.
Then we need to duplicate PHI nodes at <L2> and rewrite b_1 into SSA.

CCing Jeff as I think this PR fits very naturally to the jump threading
algogorithm in DOM.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at redhat dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]