This is the mail archive of the gcc-patches@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]

Re: [PATCH] Make LIM able to hoist PHI nodes


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]