This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] DCE and conditionals
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>
- Date: Mon, 5 May 2003 16:11:05 -0400
- Subject: Re: [tree-ssa] DCE and conditionals
- Organization: Red Hat Canada
- References: <1052137908.19625.1223.camel@p4>
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.