This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[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
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jan 2005 20:39:19 -0000
- Subject: [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
- References: <20041024233535.18133.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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