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: [PATCH][5/n] tree LIM TLC


On Tue, 12 Mar 2013, Steven Bosscher wrote:

> On Tue, Mar 12, 2013 at 4:16 PM, Richard Biener wrote:
> > --- 127,145 ----
> >                                 /* The locations of the accesses.  Vector
> >                                    indexed by the loop number.  */
> >
> > !   /* The following sets are computed on demand.  We use two bits per
> > !      information to represent the not-computed state.  */
> > !
> > !   /* The set of loops in that the memory reference is independent
> > !      (2 * loop->num) or dependent (2 * loop->num + 1) in.
> > !      If it is stored in the loop, this store is independent on all other
> > !      loads and stores.
> > !      If it is only loaded, then it is independent on all stores in the loop.  */
> > !   bitmap loop_dependence;
> > !
> > !   /* The set of memory references on that this reference is independent
> > !      (2 * mem->id) or dependent (2 * mem->id + 1).  */
> > !   bitmap ref_dependence;
> >   } *mem_ref_p;
> 
> Perhaps add simple inline functions to test those bits, to avoid:
> 
> > --- 2174,2182 ----
> >         ref2 = tem;
> >       }
> >
> > !   if (bitmap_bit_p (ref1->ref_dependence, 2 * ref2->id))
> >       return true;
> > !   if (bitmap_bit_p (ref1->ref_dependence, 2 * ref2->id + 1))
> >       return false;
> >
> >     if (dump_file && (dump_flags & TDF_DETAILS))
> 
> ?
> 
> That kind of explicit 2*x+[01] is bound to go wrong at some point.

Yeah, like with the following - also replaced bitmap by
bitmap_head as you suggested in the other mail (others to
follow in a separate patch).

Bootstrap / test scheduled before the commit for 4.9.

Thanks,
Richard.

2013-03-13  Richard Biener  <rguenther@suse.de>

	* tree-ssa-loop-im.c (struct mem_ref): Merge indep_loop and
	dep_loop into loop_dependence, merge indep_ref and dep_ref
	into ref_dependence.  Use a bitmap_head for those.
	(DEP_BIT, INDEP_BIT): New macros to compute the bit used
	for dependence and independence information.
	(mem_ref_alloc): Adjust.
	(refs_independent_p): Likewise.
	(record_indep_loop): Likewise.
	(ref_indep_loop_p): Likewise.

Index: trunk/gcc/tree-ssa-loop-im.c
===================================================================
*** trunk.orig/gcc/tree-ssa-loop-im.c	2013-03-13 12:47:04.000000000 +0100
--- trunk/gcc/tree-ssa-loop-im.c	2013-03-13 12:53:47.884467097 +0100
*************** typedef struct mem_ref
*** 127,149 ****
  				/* The locations of the accesses.  Vector
  				   indexed by the loop number.  */
  
!   /* The following sets are computed on demand.  We keep both set and
!      its complement, so that we know whether the information was
!      already computed or not.  */
!   bitmap indep_loop;		/* The set of loops in that the memory
! 				   reference is independent, meaning:
! 				   If it is stored in the loop, this store
! 				     is independent on all other loads and
! 				     stores.
! 				   If it is only loaded, then it is independent
! 				     on all stores in the loop.  */
!   bitmap dep_loop;		/* The complement of INDEP_LOOP.  */
! 
!   bitmap indep_ref;		/* The set of memory references on that
! 				   this reference is independent.  */
!   bitmap dep_ref;		/* The complement of INDEP_REF.  */
  } *mem_ref_p;
  
  
  
  
--- 127,149 ----
  				/* The locations of the accesses.  Vector
  				   indexed by the loop number.  */
  
!   /* The following sets are computed on demand.  We use two bits per
!      information to represent the not-computed state.  */
! 
!   /* The set of loops in that the memory reference is independent
!      (2 * loop->num) or dependent (2 * loop->num + 1) in.
!      If it is stored in the loop, this store is independent on all other
!      loads and stores.
!      If it is only loaded, then it is independent on all stores in the loop.  */
!   bitmap_head loop_dependence;
! 
!   /* The set of memory references on that this reference is independent
!      (2 * mem->id) or dependent (2 * mem->id + 1).  */
!   bitmap_head ref_dependence;
  } *mem_ref_p;
  
+ #define INDEP_BIT(n) ((n) * 2)
+ #define DEP_BIT(n) ((n) * 2 + 1)
  
  
  
*************** mem_ref_alloc (tree mem, unsigned hash,
*** 1481,1490 ****
    ref->id = id;
    ref->hash = hash;
    ref->stored = BITMAP_ALLOC (&lim_bitmap_obstack);
!   ref->indep_loop = BITMAP_ALLOC (&lim_bitmap_obstack);
!   ref->dep_loop = BITMAP_ALLOC (&lim_bitmap_obstack);
!   ref->indep_ref = BITMAP_ALLOC (&lim_bitmap_obstack);
!   ref->dep_ref = BITMAP_ALLOC (&lim_bitmap_obstack);
    ref->accesses_in_loop.create (0);
  
    return ref;
--- 1481,1488 ----
    ref->id = id;
    ref->hash = hash;
    ref->stored = BITMAP_ALLOC (&lim_bitmap_obstack);
!   bitmap_initialize (&ref->loop_dependence, &lim_bitmap_obstack);
!   bitmap_initialize (&ref->ref_dependence, &lim_bitmap_obstack);
    ref->accesses_in_loop.create (0);
  
    return ref;
*************** refs_independent_p (mem_ref_p ref1, mem_
*** 2178,2186 ****
        ref2 = tem;
      }
  
!   if (bitmap_bit_p (ref1->indep_ref, ref2->id))
      return true;
!   if (bitmap_bit_p (ref1->dep_ref, ref2->id))
      return false;
  
    if (dump_file && (dump_flags & TDF_DETAILS))
--- 2176,2184 ----
        ref2 = tem;
      }
  
!   if (bitmap_bit_p (&ref1->ref_dependence, INDEP_BIT (ref2->id)))
      return true;
!   if (bitmap_bit_p (&ref1->ref_dependence, DEP_BIT (ref2->id + 1)))
      return false;
  
    if (dump_file && (dump_flags & TDF_DETAILS))
*************** refs_independent_p (mem_ref_p ref1, mem_
*** 2190,2203 ****
    if (mem_refs_may_alias_p (ref1->mem, ref2->mem,
  			    &memory_accesses.ttae_cache))
      {
!       bitmap_set_bit (ref1->dep_ref, ref2->id);
        if (dump_file && (dump_flags & TDF_DETAILS))
  	fprintf (dump_file, "dependent.\n");
        return false;
      }
    else
      {
!       bitmap_set_bit (ref1->indep_ref, ref2->id);
        if (dump_file && (dump_flags & TDF_DETAILS))
  	fprintf (dump_file, "independent.\n");
        return true;
--- 2188,2201 ----
    if (mem_refs_may_alias_p (ref1->mem, ref2->mem,
  			    &memory_accesses.ttae_cache))
      {
!       bitmap_set_bit (&ref1->ref_dependence, DEP_BIT (ref2->id));
        if (dump_file && (dump_flags & TDF_DETAILS))
  	fprintf (dump_file, "dependent.\n");
        return false;
      }
    else
      {
!       bitmap_set_bit (&ref1->ref_dependence, INDEP_BIT (ref2->id));
        if (dump_file && (dump_flags & TDF_DETAILS))
  	fprintf (dump_file, "independent.\n");
        return true;
*************** static void
*** 2211,2219 ****
  record_indep_loop (struct loop *loop, mem_ref_p ref, bool indep)
  {
    if (indep)
!     bitmap_set_bit (ref->indep_loop, loop->num);
    else
!     bitmap_set_bit (ref->dep_loop, loop->num);
  }
  
  /* Returns true if REF is independent on all other memory references in
--- 2209,2217 ----
  record_indep_loop (struct loop *loop, mem_ref_p ref, bool indep)
  {
    if (indep)
!     bitmap_set_bit (&ref->loop_dependence, INDEP_BIT (loop->num));
    else
!     bitmap_set_bit (&ref->loop_dependence, DEP_BIT (loop->num));
  }
  
  /* Returns true if REF is independent on all other memory references in
*************** ref_indep_loop_p (struct loop *loop, mem
*** 2256,2264 ****
  {
    bool ret;
  
!   if (bitmap_bit_p (ref->indep_loop, loop->num))
      return true;
!   if (bitmap_bit_p (ref->dep_loop, loop->num))
      return false;
  
    ret = ref_indep_loop_p_1 (loop, ref);
--- 2254,2262 ----
  {
    bool ret;
  
!   if (bitmap_bit_p (&ref->loop_dependence, INDEP_BIT (loop->num)))
      return true;
!   if (bitmap_bit_p (&ref->loop_dependence, DEP_BIT (loop->num)))
      return false;
  
    ret = ref_indep_loop_p_1 (loop, ref);


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