This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make LIM able to hoist PHI nodes
- From: Michael Matz <matz at suse dot de>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, Zdenek Dvorak <ook at ucw dot cz>
- Date: Mon, 3 May 2010 16:35:42 +0200 (CEST)
- Subject: Re: [PATCH] Make LIM able to hoist PHI nodes
- References: <alpine.LNX.2.00.1005031208000.1429@zhemvz.fhfr.qr>
Hi,
On Mon, 3 May 2010, Richard Guenther wrote:
> + /* From a controlling predicate in DOM determine the arguments from
> + the PHI node PHI that are chosen if the predicate evaluates to
> + true and false and store them to *TRUE_ARG_P and *FALSE_ARG_P if
> + they are non-NULL. Returns true if the arguments can be determined,
> + else return false. */
> +
> + static bool
> + extract_true_false_args_from_phi (basic_block dom, gimple phi,
> + tree *true_arg_p, tree *false_arg_p)
> + {
> + basic_block bb = gimple_bb (phi);
> + edge true_edge, false_edge, tem;
> + tree arg0 = NULL_TREE, arg1 = NULL_TREE;
> +
> + extract_true_false_edges_from_block (dom, &true_edge, &false_edge);
> + tem = EDGE_PRED (bb, 0);
> + if (tem == true_edge
> + || tem->src == true_edge->dest
> + || dominated_by_p (CDI_DOMINATORS,
> + tem->src, true_edge->dest))
> + arg0 = PHI_ARG_DEF (phi, tem->dest_idx);
> + else if (tem == false_edge
> + || tem->src == false_edge->dest
> + || dominated_by_p (CDI_DOMINATORS,
> + tem->src, false_edge->dest))
> + arg1 = PHI_ARG_DEF (phi, tem->dest_idx);
> + else
> + return false;
> + tem = EDGE_PRED (bb, 1);
> + if (tem == true_edge
> + || tem->src == true_edge->dest
> + || dominated_by_p (CDI_DOMINATORS,
> + tem->src, true_edge->dest))
> + arg0 = PHI_ARG_DEF (phi, tem->dest_idx);
> + else if (tem == false_edge
> + || tem->src == false_edge->dest
> + || dominated_by_p (CDI_DOMINATORS,
> + tem->src, false_edge->dest))
> + arg1 = PHI_ARG_DEF (phi, tem->dest_idx);
> + else
> + return false;
As you might remember this routine was slightly complicated to get right,
and we can't put photos of our whiteboard in the sources :-) So, if you
could put a comment in there explaining which cases it handles and why
that handling is correct...
Ciao,
Michael.