[PATCH][RFC] Get back what DCE was able to do in 4.2 with V_MUST_DEFs

Richard Guenther rguenther@suse.de
Fri Sep 28 14:11:00 GMT 2007


On Thu, 27 Sep 2007, Zdenek Dvorak wrote:

> Hello,
> 
> > *************** remove_dead_stmt (block_stmt_iterator *i
> > *** 648,654 ****
> >             remove_edge (EDGE_SUCC (bb, 1));
> >   	}
> >       }
> > !   
> >     bsi_remove (i, true);  
> >     release_defs (t); 
> >   }
> > --- 698,735 ----
> >             remove_edge (EDGE_SUCC (bb, 1));
> >   	}
> >       }
> > ! 
> > !   /* Update uses of VDEFs in t.  */
> > !   FOR_EACH_SSA_VDEF_OPERAND (def_p, usevect, t, iter)
> > !     {
> > !       imm_use_iterator iter2;
> > !       use_operand_p use_p;
> > !       tree stmt, use;
> > ! 
> > !       gcc_assert (VUSE_VECT_NUM_ELEM (*usevect) == 1);
> > ! 
> > !       use = VUSE_ELEMENT_VAR (*usevect, 0);
> > ! 
> > !       /* If we are messing with a use defined in a loop PHI, make us
> > ! 	 propagate the default def instead.  */
> > !       FOR_EACH_IMM_USE_FAST (use_p, iter2, DEF_FROM_PTR (def_p))
> > ! 	if (TREE_CODE (USE_STMT (use_p)) == PHI_NODE
> > ! 	    && PHI_RESULT_TREE (USE_STMT (use_p)) == use)
> > ! 	  {
> > ! 	    use = gimple_default_def (cfun, SSA_NAME_VAR (use));
> > ! 	    break;
> > ! 	  }
> 
> what is the purpose of this hack (why do you need to use the default
> def)?  And why is it even correct (it seems that this should create
> overlaping life ranges for virtual operand SSA names)?  I think it
> needs to be also explained in the comment.

The default def is the only one that doesn't need a def.  Basically
I was getting used but freed SSA_NAMEs all over the place.  So yes,
I'm not sure this will not generate wrong code ;)  Probably just giving
up if PHIs are involved might be the better idea.

> 
> > !       FOR_EACH_IMM_USE_STMT (stmt, iter2, DEF_FROM_PTR (def_p))
> > ! 	FOR_EACH_IMM_USE_ON_STMT (use_p, iter2)
> > ! 	  SET_USE (use_p, use);
> 
> This should use replace_uses_by (otherwise you are missing at least
> updating SSA_NAME_OCCURS_IN_ABNORMAL_PHI).

Indeed.  Though replace_uses_by looks like overkill as I'm only
replacing virtual operands here.

As Diego ditched the idea of hacking DCE I'm not going to spend more
time on this patch anyway.  And the bootstrap failed at

../../../../trunk/libstdc++-v3/src/pool_allocator.cc:176: internal 
compiler error: in value_format, at dwarf2out.c:6957
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[4]: *** [pool_allocator.lo] Error 1

now in building libstdc++v3.  No idea if this is related ;)

Richard.



More information about the Gcc-patches mailing list