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 21:09 -------
Here is another idea that would not compilicate the DOM.
That is, we can set up things so that the actual threading part will be
done by DOM.

Suppose we have a factored computed goto block like so:

  # p_2 = PHI <&L0(0), &L1(1), p_3(2)>;
  # b_1 = PHI <3(0), 5(1), 4(2)>;
<L2>:;
  ... possibly some other statements ...
  goto p_2;


Let's split this block like so:


  # p_2 = PHI <&L0(0), &L1(1), p_3(2)>;
  # b_1 = PHI <3(0), 5(1), 4(2)>;
<L2>:;
  ... possibly some other statements ...

<L3>:;      // fall through from L2.
  goto p_2;


Note that we are still in SSA form without need for rewriting.

Now let's add a new PHI node and a new SWITCH_EXPR to <L2> like so:


  # p_2 = PHI <&L0(0), &L1(1), p_3(2)>;
  # b_1 = PHI <3(0), 5(1), 4(2)>;
  # fac_1 = PHI <0(0), 1(1), 2(2)>;
<L2>:;
  ... possibly some other statements ...
  switch (fac_1)
    {
    case 0: goto L0;    <- a threadable, normal edge
    case 1: goto L1;    <- a threadable, normal edge
    default: goto <L3>; <- not threadable because p_3 is an SSA_NAME
    }

<L3>:;
  goto p_2;

That is, we create a new PHI node fac_1 so that we can build a
dispatch table using a SWITCH_EXPR.

Now it's easy for DOM to pick up the jump threading opportunities at
SWITCH_EXPR.

If you like, you can say that we "reduce" the factored computed goto
block to a SWITCH_EXPR.

Any thoughts?

-- 


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]