[tree-ssa] DCE and conditionals
Diego Novillo
dnovillo@redhat.com
Mon May 5 20:11:00 GMT 2003
On Mon, May 05, 2003 at 08:31:47AM -0400, Andrew MacLeod wrote:
> (linearize_condition_expr also needs to be taught that if an IF has an
> empty then and else block, it still can't be removed if there is a PHI
> node in the immediate postdominator of the if.)
>
Actually, this is all we need. What you described is a bug in
the flow graph linearizer. Those statements are quite dead
because they don't feed the live PHI node anymore. The flow
graph cleanup pass needs to understand that the presence of PHI
nodes means that the structure of the graph needs to be
preserved. A kind of structural liveness.
The same principle applies to unstructured flow. The linearizer
cannot remove the blocks that feed a PHI node. Granted, if all
the arguments are the same, then we can convert the PHI node into
a copy operation. That also should be part of the cleanup pass.
> PS then we have a case like :
>
>
>
> if (t_5>0)
> a_2 = a_1;
> else
> a_3 = a_0;
> lab:
> a5 = PHI (a_2, a_3, a_4) /* a_4 comes in from a goto lab:. */
>
After fixing the flow graph linearizer, this should be converted
into:
if ((void)0)
(void)0;
else
(void)0;
lab:
a_5 = PHI <a_1, a_0, a_4>
Note how the COND_EXPR is only kept because it provides the
structure needed to feed that PHI node. If all 'a's coalesce
together, then SSA->normal could remove the empty skeleton for
the if().
Diego.
More information about the Gcc
mailing list