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: [tree-ssa]: PRE updates


On Wed, 2003-06-11 at 09:11, Diego Novillo wrote:
> On Wed, 2003-06-11 at 09:02, Andrew MacLeod wrote:
> 
> > *** tree-cfg.c	9 Jun 2003 22:37:01 -0000	1.1.4.104
> > --- tree-cfg.c	11 Jun 2003 12:59:47 -0000
> > *************** handle_switch_split (basic_block src, ba
> > *** 3679,3684 ****
> > --- 3679,3686 ----
> >   	      tree new_phi;
> >   	      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (phi)),
> >   					 new_bb);
> > + 	      create_var_ann (PHI_RESULT (new_phi));
> > + 
> >   	      /* Add elements to the new PHI node.  */
> >   	      for (i = 0; i < num_elems; i++)
> >   	        {
> > 
> Hmm, I wonder if this is related to a similar problem we're having with
> perl in SPEC95 that you pointed me to last week.  Is this the first time
> that that variable has been referenced?  If there are other references
> to that variable in the program, then it ought to have an annotation
> already.
> 

This variable has just been created because I needed new PHIs. It
wasn;'t in the code base until friday, and its only used when a critical
edge has been split in a switch stmt which causes the creation of 2 new
basic blocks, and a new PHI stmt to handle the new flow.

So thats not the problem in spec or anywhere else except Dans code..
he's the first to execute this path.  :-)

> In which case, the bug is most likely in find_vars_r.  Forcing the
> creation of an annotation here wouldn't be right in that case.
> 

I am creating the variable in the previous stmt, so it has no annotation
yet. out of ssa look sat the annotation, and expects there to be on. I
have a new patch at the bottom. Out of ssa is going to ignore this
variable right now because has_real_ref isn't set.

This PHI is created because:

  case A:
    if (x)
       then
         .... (BB 4)
       else
         ...  (BB 5)
   /* Fallthru */
  case B:
    a_4 = PHI <a_1(2), a_2(4), a_3(5)>

The edge to case B from the switch needs to be split. We now generate:

   case A:
    if (x) 
       then
         .... (BB 4)
       else
         ...  (BB 5)
   /* Fallthru */
   /* New BB 7 */
   a_5 = PHI <a_2(4), a_3(5)>
   goto LABEL;
   case B:
   /* New BB 8 */
     <inserted stmt>
LABEL:
   a_4 = PHI <a_1(8), a_5(7)>


SO the code you are looking at above created thge a_5 PHI stmt... Its
a_5 I am creating the var_ann for, because I just created it out of thin
air.

Anyway, here's the patch which I beleive to be correct.


	* tree-cfg.c (handle_switch_split): Create var annotation for new 
	PHI result.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.104
diff -c -p -r1.1.4.104 tree-cfg.c
*** tree-cfg.c	9 Jun 2003 22:37:01 -0000	1.1.4.104
--- tree-cfg.c	11 Jun 2003 13:19:49 -0000
*************** handle_switch_split (basic_block src, ba
*** 3677,3684 ****
--- 3677,3688 ----
  	  for (; phi; phi = TREE_CHAIN (phi))
  	    {
  	      tree new_phi;
+ 	      var_ann_t ann;
  	      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (phi)),
  					 new_bb);
+ 	      ann = create_var_ann (PHI_RESULT (new_phi));
+ 	      ann->has_real_refs = var_ann (PHI_RESULT (phi))->has_real_refs;
+ 
  	      /* Add elements to the new PHI node.  */
  	      for (i = 0; i < num_elems; i++)
  	        {


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