Message ID | 4E9E8903.5040808@mentor.com |
---|---|
State | New |
Headers | show |
On Wed, Oct 19, 2011 at 10:23 AM, Tom de Vries <Tom_deVries@mentor.com> wrote: > Richard, > > For the example from the PR, -ftree-tail-merge discovers that blocks 6 and 7 are > equal, removes block 7 and redirects the outgoing edge of it's predecessor block > 11 to block 6. > > Block 6 contains a phi, which after redirecting the edge from block 11 looks > like this: > ... > .MEM_54 = PHI <.MEM_27(18), .MEM_26(17), (11)> > ... > > Since update_vops is false, TODO_update_ssa_only_virtuals will be run > and -ftree-tail-merge doesn't update the phi. > > However during cleanup_tree_cfg (which is done before updating the ssa), > phi_alternatives_equal is called which asserts that the phi arguments are defined. > > The patch fixes the ICE by setting the empty phi argument to .MEM. > > bootstrapped and reg-tested on x86_64. > > Ok for trunk? Ok. Thanks, Richard. > Thanks, > - Tom > > 2011-10-19 Tom de Vries <tom@codesourcery.com> > > PR 50769/tree-optimization > * tree-ssa-tail-merge.c (replace_block_by): Calculate phi_vuse2 > unconditionally. Handle case that phi_vuse2 is not an SSA_NAME. Add > dummy argument .MEM to phi when increasing number of arguments of phi by > redirecting edges to the block with phi. >
Index: gcc/tree-ssa-tail-merge.c =================================================================== --- gcc/tree-ssa-tail-merge.c (revision 179773) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -1470,11 +1470,14 @@ replace_block_by (basic_block bb1, basic edge e; edge_iterator ei; + phi_vuse2 = vop_at_entry (bb2); + if (phi_vuse2 != NULL_TREE && TREE_CODE (phi_vuse2) != SSA_NAME) + phi_vuse2 = NULL_TREE; + if (update_vops) { /* Find the vops at entry of bb1 and bb2. */ phi_vuse1 = vop_at_entry (bb1); - phi_vuse2 = vop_at_entry (bb2); /* If one of the 2 not found, it means there's no need to update. */ update_vops = phi_vuse1 != NULL_TREE && phi_vuse2 != NULL_TREE; @@ -1507,6 +1510,9 @@ replace_block_by (basic_block bb1, basic gcc_assert (pred_edge != NULL); if (update_vops) VEC_safe_push (edge, heap, redirected_edges, pred_edge); + else if (phi_vuse2 && gimple_bb (SSA_NAME_DEF_STMT (phi_vuse2)) == bb2) + add_phi_arg (SSA_NAME_DEF_STMT (phi_vuse2), SSA_NAME_VAR (phi_vuse2), + pred_edge, UNKNOWN_LOCATION); } /* Update the vops. */