[patch] Fix PR43464: update loop closed SSA form once copy prop is done
Zdenek Dvorak
rakdver@kam.mff.cuni.cz
Tue Mar 30 14:52:00 GMT 2010
Hi,
> > sure -- just check whether at least one predecessor edge of the block in that the phi node is located
> > is a loop exit (this is unnecessarily conservative, of course, but so is the current code),
>
> Something like the following? (I don't want to rely on recorded
> loop exits)
almost -- this would also return true for loop entry edges. I'd suggest
loop_exit_edge_p (e->src->loop_father, e)
Zdenek
> Sebastian - does this fix your testcase?
>
> Thanks,
> Richard.
>
> Index: gcc/tree-ssa-copy.c
> ===================================================================
> --- gcc/tree-ssa-copy.c (revision 157820)
> +++ gcc/tree-ssa-copy.c (working copy)
> @@ -749,6 +749,7 @@ init_copy_prop (void)
> {
> gimple_stmt_iterator si;
> int depth = bb->loop_depth;
> + bool loop_exit_p = false;
>
> for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
> {
> @@ -786,6 +787,18 @@ init_copy_prop (void)
> cached_last_copy_of[SSA_NAME_VERSION (def)] = def;
> }
>
> + /* In loop-closed SSA form do not copy-propagate through
> + PHI nodes in blocks with a loop exit edge predecessor. */
> + if (current_loops
> + && loops_state_satisfies_p (LOOP_CLOSED_SSA))
> + {
> + edge_iterator ei;
> + edge e;
> + FOR_EACH_EDGE (e, ei, bb->preds)
> + if (e->src->loop_father != e->dest->loop_father)
> + loop_exit_p = true;
> + }
> +
> for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
> {
> gimple phi = gsi_stmt (si);
> @@ -793,12 +806,7 @@ init_copy_prop (void)
>
> def = gimple_phi_result (phi);
> if (!is_gimple_reg (def)
> - /* In loop-closed SSA form do not copy-propagate through
> - PHI nodes. Technically this is only needed for loop
> - exit PHIs, but this is difficult to query. */
> - || (current_loops
> - && gimple_phi_num_args (phi) == 1
> - && loops_state_satisfies_p (LOOP_CLOSED_SSA)))
> + || loop_exit_p)
> prop_set_simulate_again (phi, false);
> else
> prop_set_simulate_again (phi, true);
More information about the Gcc-patches
mailing list