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

[patch] Re: recount_dominator


Hello,

> Joern Rennecke wrote:
> >From the code, it almost looks as if it tries to recompute
> >the dominator,
> 
> That is what it looks like to me also.
> 
> >except this it seems nonsentical for
> >(dir ==  CDI_POST_DOMINATORS) to loop through the predecessors
> >of bb.
> 
> Yes, this looks like a bug.

latent since we never use it for postdominators (for now).  Anyway, here
is the patch that improves comment and handles the postdominators
correctly.

Bootstrapped & regtested on i686.

Zdenek

	* dominance.c (recount_dominator): Handle postdominators.

Index: dominance.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dominance.c,v
retrieving revision 1.21
diff -c -3 -p -r1.21 dominance.c
*** dominance.c	21 Jan 2004 20:39:53 -0000	1.21
--- dominance.c	28 Feb 2004 09:42:36 -0000
*************** verify_dominators (enum cdi_direction di
*** 769,791 ****
      abort ();
  }
  
! /* Recount dominator of BB.  */
  basic_block
  recount_dominator (enum cdi_direction dir, basic_block bb)
  {
!    basic_block dom_bb = NULL;
!    edge e;
  
    if (!dom_computed[dir])
      abort ();
  
!    for (e = bb->pred; e; e = e->pred_next)
!      {
!        if (!dominated_by_p (dir, e->src, bb))
!          dom_bb = nearest_common_dominator (dir, dom_bb, e->src);
!      }
  
!    return dom_bb;
  }
  
  /* Iteratively recount dominators of BBS. The change is supposed to be local
--- 769,806 ----
      abort ();
  }
  
! /* Determine immediate dominator (or postdominator, according to DIR) of BB,
!    assuming that dominators of other blocks are correct.  We also use it to
!    recompute the dominators in a restricted area, by iterating it until it
!    reaches a fixpoint.  */
! 
  basic_block
  recount_dominator (enum cdi_direction dir, basic_block bb)
  {
!   basic_block dom_bb = NULL;
!   edge e;
  
    if (!dom_computed[dir])
      abort ();
  
!   if (dir == CDI_DOMINATORS)
!     {
!       for (e = bb->pred; e; e = e->pred_next)
! 	{
! 	  if (!dominated_by_p (dir, e->src, bb))
! 	    dom_bb = nearest_common_dominator (dir, dom_bb, e->src);
! 	}
!     }
!   else
!     {
!       for (e = bb->succ; e; e = e->succ_next)
! 	{
! 	  if (!dominated_by_p (dir, e->dest, bb))
! 	    dom_bb = nearest_common_dominator (dir, dom_bb, e->dest);
! 	}
!     }
  
!   return dom_bb;
  }
  
  /* Iteratively recount dominators of BBS. The change is supposed to be local


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