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]

Ger rid of RBIs at trees, resent


Hi,
either I am blind or this mail didn't get archived (I seem to be pretty
certain I posed it).  This kills the RBIs datastructure on trees and if
it seems reonable, I would like to proceed by killing RBIs completely as
mentioned in my previous mail and get some other of sparse things out of
CFG datastructure to hashtable...

Honza

Hi,
currently CFG and stmt annotations accounts about 40% of overall memory
usage after parsing (so before we start actually compiling functions),
so I would like to get rid of things we don't need to keep
interprocedurally alive.  One of easy starts seems to be the rbi
datastructure that is mostly RTL centric but somehow it happened to be
neccesary for every basic block in tree level just to keep mapping
between basic blocks and their's copies when duplicating regions.

Since this seems to be used across number of modules it seems sane to
have generic interface for this and since most of basic blocks won't be
copied or being copies it seems sane to use hashtable for it, thus I
made the attached patch where I have hastables to keep this mapping and
use rbis only in the RTL level.

It saves roughly 8% of the overall memory usage in my statistics.  If
this approach seems to make sense, I think I would proceed by hashtables
for some of other sparse datastructures - instructions emitted to edges,
goto_locators and such comes to mind.
I would also like to split out all the RTL centric datastructures
(liveness bitmaps, what is currently in RBI) into rtl_bb_info
datastructure replacing current RBI pointer.

Does this plan seem to make sense (hashtable explossion seems bit weird
to me but I can't find much better alternative)?  (the patch
bootstraps/regresses i686-pc-gnu-linux)

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.259
diff -c -3 -p -r1.259 basic-block.h
*** basic-block.h	28 May 2005 21:19:59 -0000	1.259
--- basic-block.h	31 May 2005 20:19:39 -0000
*************** struct reorder_block_def GTY(())
*** 283,298 ****
  
    basic_block next;
  
-   /* These pointers may be unreliable as the first is only used for
-      debugging (and should probably be removed, and the second is only
-      used by copying.  The basic blocks pointed to may be removed and
-      that leaves these pointers pointing to garbage.  */
-   basic_block GTY ((skip (""))) original;
-   basic_block GTY ((skip (""))) copy;
- 
-   int duplicated;
-   int copy_number;
- 
    /* This field is used by the bb-reorder and tracer passes.  */
    int visited;
  };
--- 283,288 ----
*************** enum
*** 336,342 ****
    BB_HOT_PARTITION = 64,
  
    /* Set on blocks that should be put in a cold section.  */
!   BB_COLD_PARTITION = 128
  };
  
  /* Dummy flag for convenience in the hot/cold partitioning code.  */
--- 326,335 ----
    BB_HOT_PARTITION = 64,
  
    /* Set on blocks that should be put in a cold section.  */
!   BB_COLD_PARTITION = 128,
! 
!   /* Set on block that was duplicated.  */
!   BB_DUPLICATED = 256
  };
  
  /* Dummy flag for convenience in the hot/cold partitioning code.  */
*************** extern void break_superblocks (void);
*** 991,996 ****
--- 984,996 ----
  extern void check_bb_profile (basic_block, FILE *);
  extern void update_bb_profile_for_threading (basic_block, int, gcov_type, edge);
  
+ extern void initialize_original_copy_tables (void);
+ extern void free_original_copy_tables (void);
+ extern void set_bb_original (basic_block, basic_block);
+ extern basic_block get_bb_original (basic_block);
+ extern void set_bb_copy (basic_block, basic_block);
+ extern basic_block get_bb_copy (basic_block);
+ 
  #include "cfghooks.h"
  
  #endif /* GCC_BASIC_BLOCK_H */
Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.92
diff -c -3 -p -r1.92 cfg.c
*** cfg.c	12 May 2005 22:32:08 -0000	1.92
--- cfg.c	31 May 2005 20:19:40 -0000
*************** Software Foundation, 59 Temple Place - S
*** 63,68 ****
--- 63,70 ----
  #include "obstack.h"
  #include "timevar.h"
  #include "ggc.h"
+ #include "hashtab.h"
+ #include "alloc-pool.h"
  
  /* The obstack on which the flow graph components are allocated.  */
  
*************** scale_bbs_frequencies_gcov_type (basic_b
*** 939,941 ****
--- 941,1081 ----
  	e->count = (e->count * num) /den;
      }
  }
+ 
+ /* Datastructures used to maintain mapping between basic blocks and copies.  */
+ static htab_t bb_original;
+ static htab_t bb_copy;
+ static alloc_pool original_copy_bb_pool;
+ 
+ struct htab_bb_copy_original_entry
+ {
+   /* Block we are attaching info to.  */
+   int index1;
+   /* Index of original or copy (depending on the hashtable) */
+   int index2;
+ };
+ 
+ static hashval_t
+ bb_copy_original_hash (const void *p)
+ {
+   struct htab_bb_copy_original_entry *data = ((struct htab_bb_copy_original_entry *)p);
+ 
+   return data->index1;
+ }
+ static int
+ bb_copy_original_eq (const void *p, const void *q)
+ {
+   struct htab_bb_copy_original_entry *data = ((struct htab_bb_copy_original_entry *)p);
+   struct htab_bb_copy_original_entry *data2 = ((struct htab_bb_copy_original_entry *)q);
+ 
+   return data->index1 == data2->index1;
+ }
+ 
+ /* Initialize the datstructures to maintain mapping between blocks and it's copies.  */
+ void
+ initialize_original_copy_tables (void)
+ {
+   gcc_assert (!original_copy_bb_pool);
+   original_copy_bb_pool
+     = create_alloc_pool ("original_copy",
+ 			 sizeof (struct htab_bb_copy_original_entry), 10);
+   bb_original = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL);
+   bb_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL);
+ }
+ 
+ /* Free the datstructures to maintain mapping between blocks and it's copies.  */
+ void
+ free_original_copy_tables (void)
+ {
+   gcc_assert (original_copy_bb_pool);
+   htab_delete (bb_copy);
+   htab_delete (bb_original);
+   free_alloc_pool (original_copy_bb_pool);
+   bb_copy = NULL;
+   bb_original = NULL;
+   original_copy_bb_pool = NULL;
+ }
+ 
+ /* Set original for basic block.  Do nothing when datstructures are not
+    intialized so passes not needing this don't need to care.  */
+ void
+ set_bb_original (basic_block bb, basic_block original)
+ {
+   if (original_copy_bb_pool)
+     {
+       struct htab_bb_copy_original_entry **slot;
+       struct htab_bb_copy_original_entry key;
+ 
+       key.index1 = bb->index;
+       slot =
+ 	(struct htab_bb_copy_original_entry **) htab_find_slot (bb_original,
+ 							       &key, INSERT);
+       if (*slot)
+ 	(*slot)->index2 = original->index;
+       else
+ 	{
+ 	  *slot = pool_alloc (original_copy_bb_pool);
+ 	  (*slot)->index1 = bb->index;
+ 	  (*slot)->index2 = original->index;
+ 	}
+     }
+ }
+ 
+ /* Get the original basic block.  */
+ basic_block
+ get_bb_original (basic_block bb)
+ {
+   struct htab_bb_copy_original_entry *entry;
+   struct htab_bb_copy_original_entry key;
+ 
+   gcc_assert (original_copy_bb_pool);
+ 
+   key.index1 = bb->index;
+   entry = (struct htab_bb_copy_original_entry *) htab_find (bb_original, &key);
+   if (entry)
+     return BASIC_BLOCK (entry->index2);
+   else
+     return NULL;
+ }
+ 
+ /* Set copy for basic block.  Do nothing when datstructures are not
+    intialized so passes not needing this don't need to care.  */
+ void
+ set_bb_copy (basic_block bb, basic_block copy)
+ {
+   if (original_copy_bb_pool)
+     {
+       struct htab_bb_copy_original_entry **slot;
+       struct htab_bb_copy_original_entry key;
+ 
+       key.index1 = bb->index;
+       slot =
+ 	(struct htab_bb_copy_original_entry **) htab_find_slot (bb_copy,
+ 							       &key, INSERT);
+       if (*slot)
+ 	(*slot)->index2 = copy->index;
+       else
+ 	{
+ 	  *slot = pool_alloc (original_copy_bb_pool);
+ 	  (*slot)->index1 = bb->index;
+ 	  (*slot)->index2 = copy->index;
+ 	}
+     }
+ }
+ 
+ /* Get the copy of basic block.  */
+ basic_block
+ get_bb_copy (basic_block bb)
+ {
+   struct htab_bb_copy_original_entry *entry;
+   struct htab_bb_copy_original_entry key;
+ 
+   gcc_assert (original_copy_bb_pool);
+ 
+   key.index1 = bb->index;
+   entry = (struct htab_bb_copy_original_entry *) htab_find (bb_copy, &key);
+   if (entry)
+     return BASIC_BLOCK (entry->index2);
+   else
+     return NULL;
+ }
Index: cfghooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfghooks.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 cfghooks.c
*** cfghooks.c	26 May 2005 18:14:38 -0000	1.27
--- cfghooks.c	31 May 2005 20:19:40 -0000
*************** duplicate_block (basic_block bb, edge e)
*** 756,763 ****
        new_bb->frequency = bb->frequency;
      }
  
!   new_bb->rbi->original = bb;
!   bb->rbi->copy = new_bb;
  
    return new_bb;
  }
--- 756,763 ----
        new_bb->frequency = bb->frequency;
      }
  
!   set_bb_original (new_bb, bb);
!   set_bb_copy (bb, new_bb);
  
    return new_bb;
  }
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.87
diff -c -3 -p -r1.87 cfglayout.c
*** cfglayout.c	3 May 2005 16:35:17 -0000	1.87
--- cfglayout.c	31 May 2005 20:19:40 -0000
*************** fixup_reorder_chain (void)
*** 802,810 ****
  	   bb = bb->rbi->next, index++)
  	{
  	  fprintf (dump_file, " %i ", index);
! 	  if (bb->rbi->original)
  	    fprintf (dump_file, "duplicate of %i ",
! 		     bb->rbi->original->index);
  	  else if (forwarder_block_p (bb)
  		   && !LABEL_P (BB_HEAD (bb)))
  	    fprintf (dump_file, "compensation ");
--- 802,810 ----
  	   bb = bb->rbi->next, index++)
  	{
  	  fprintf (dump_file, " %i ", index);
! 	  if (get_bb_original (bb))
  	    fprintf (dump_file, "duplicate of %i ",
! 		     get_bb_original (bb)->index);
  	  else if (forwarder_block_p (bb)
  		   && !LABEL_P (BB_HEAD (bb)))
  	    fprintf (dump_file, "compensation ");
*************** cfg_layout_initialize (unsigned int flag
*** 1100,1105 ****
--- 1100,1107 ----
    FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
      initialize_bb_rbi (bb);
  
+   initialize_original_copy_tables ();
+ 
    cfg_layout_rtl_register_cfg_hooks ();
  
    record_effective_endpoints ();
*************** cfg_layout_finalize (void)
*** 1166,1171 ****
--- 1168,1175 ----
  #ifdef ENABLE_CHECKING
    verify_flow_info ();
  #endif
+ 
+   free_original_copy_tables ();
  }
  
  /* Checks whether all N blocks in BBS array can be copied.  */
*************** can_copy_bbs_p (basic_block *bbs, unsign
*** 1177,1183 ****
    int ret = true;
  
    for (i = 0; i < n; i++)
!     bbs[i]->rbi->duplicated = 1;
  
    for (i = 0; i < n; i++)
      {
--- 1181,1187 ----
    int ret = true;
  
    for (i = 0; i < n; i++)
!     bbs[i]->flags |= BB_DUPLICATED;
  
    for (i = 0; i < n; i++)
      {
*************** can_copy_bbs_p (basic_block *bbs, unsign
*** 1185,1191 ****
        edge_iterator ei;
        FOR_EACH_EDGE (e, ei, bbs[i]->succs)
  	if ((e->flags & EDGE_ABNORMAL)
! 	    && e->dest->rbi->duplicated)
  	  {
  	    ret = false;
  	    goto end;
--- 1189,1195 ----
        edge_iterator ei;
        FOR_EACH_EDGE (e, ei, bbs[i]->succs)
  	if ((e->flags & EDGE_ABNORMAL)
! 	    && (e->dest->flags & BB_DUPLICATED))
  	  {
  	    ret = false;
  	    goto end;
*************** can_copy_bbs_p (basic_block *bbs, unsign
*** 1200,1206 ****
  
  end:
    for (i = 0; i < n; i++)
!     bbs[i]->rbi->duplicated = 0;
  
    return ret;
  }
--- 1204,1210 ----
  
  end:
    for (i = 0; i < n; i++)
!     bbs[i]->flags &= ~BB_DUPLICATED;
  
    return ret;
  }
*************** copy_bbs (basic_block *bbs, unsigned n, 
*** 1235,1241 ****
        /* Duplicate.  */
        bb = bbs[i];
        new_bb = new_bbs[i] = duplicate_block (bb, NULL);
!       bb->rbi->duplicated = 1;
        /* Add to loop.  */
        add_bb_to_loop (new_bb, bb->loop_father->copy);
        /* Possibly set header.  */
--- 1239,1245 ----
        /* Duplicate.  */
        bb = bbs[i];
        new_bb = new_bbs[i] = duplicate_block (bb, NULL);
!       bb->flags |= BB_DUPLICATED;
        /* Add to loop.  */
        add_bb_to_loop (new_bb, bb->loop_father->copy);
        /* Possibly set header.  */
*************** copy_bbs (basic_block *bbs, unsigned n, 
*** 1253,1261 ****
        new_bb = new_bbs[i];
  
        dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
!       if (dom_bb->rbi->duplicated)
  	{
! 	  dom_bb = dom_bb->rbi->copy;
  	  set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
  	}
      }
--- 1257,1265 ----
        new_bb = new_bbs[i];
  
        dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
!       if (dom_bb->flags & BB_DUPLICATED)
  	{
! 	  dom_bb = get_bb_copy (dom_bb);
  	  set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
  	}
      }
*************** copy_bbs (basic_block *bbs, unsigned n, 
*** 1275,1289 ****
  	    if (edges[j] && edges[j]->src == bb && edges[j]->dest == e->dest)
  	      new_edges[j] = e;
  
! 	  if (!e->dest->rbi->duplicated)
  	    continue;
! 	  redirect_edge_and_branch_force (e, e->dest->rbi->copy);
  	}
      }
  
    /* Clear information about duplicates.  */
    for (i = 0; i < n; i++)
!     bbs[i]->rbi->duplicated = 0;
  }
  
  #include "gt-cfglayout.h"
--- 1279,1293 ----
  	    if (edges[j] && edges[j]->src == bb && edges[j]->dest == e->dest)
  	      new_edges[j] = e;
  
! 	  if (!(e->dest->flags & BB_DUPLICATED))
  	    continue;
! 	  redirect_edge_and_branch_force (e, get_bb_copy (e->dest));
  	}
      }
  
    /* Clear information about duplicates.  */
    for (i = 0; i < n; i++)
!     bbs[i]->flags &= ~BB_DUPLICATED;
  }
  
  #include "gt-cfglayout.h"
Index: cfgloopmanip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopmanip.c,v
retrieving revision 1.47
diff -c -3 -p -r1.47 cfgloopmanip.c
*** cfgloopmanip.c	9 Apr 2005 16:09:10 -0000	1.47
--- cfgloopmanip.c	31 May 2005 20:19:41 -0000
*************** update_single_exits_after_duplication (b
*** 813,831 ****
    unsigned i;
  
    for (i = 0; i < nbbs; i++)
!     bbs[i]->rbi->duplicated = 1;
  
    for (; loop->outer; loop = loop->outer)
      {
        if (!loop->single_exit)
  	continue;
  
!       if (loop->single_exit->src->rbi->duplicated)
  	loop->single_exit = NULL;
      }
  
    for (i = 0; i < nbbs; i++)
!     bbs[i]->rbi->duplicated = 0;
  }
  
  /* Duplicates body of LOOP to given edge E NDUPL times.  Takes care of updating
--- 813,831 ----
    unsigned i;
  
    for (i = 0; i < nbbs; i++)
!     bbs[i]->flags |= BB_DUPLICATED;
  
    for (; loop->outer; loop = loop->outer)
      {
        if (!loop->single_exit)
  	continue;
  
!       if (loop->single_exit->src->flags & BB_DUPLICATED)
  	loop->single_exit = NULL;
      }
  
    for (i = 0; i < nbbs; i++)
!     bbs[i]->flags &= ~BB_DUPLICATED;
  }
  
  /* Duplicates body of LOOP to given edge E NDUPL times.  Takes care of updating
*************** duplicate_loop_to_header_edge (struct lo
*** 983,995 ****
        copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop);
  
        for (i = 0; i < n; i++)
! 	new_bbs[i]->rbi->copy_number = j + 1;
  
        /* Note whether the blocks and edges belong to an irreducible loop.  */
        if (add_irreducible_flag)
  	{
  	  for (i = 0; i < n; i++)
! 	    new_bbs[i]->rbi->duplicated = 1;
  	  for (i = 0; i < n; i++)
  	    {
  	      edge_iterator ei;
--- 983,998 ----
        copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop);
  
        for (i = 0; i < n; i++)
! 	{
! 	  gcc_assert (!new_bbs[i]->aux);
! 	  new_bbs[i]->aux = (void *)(size_t)(j + 1);
! 	}
  
        /* Note whether the blocks and edges belong to an irreducible loop.  */
        if (add_irreducible_flag)
  	{
  	  for (i = 0; i < n; i++)
! 	    new_bbs[i]->flags |= BB_DUPLICATED;
  	  for (i = 0; i < n; i++)
  	    {
  	      edge_iterator ei;
*************** duplicate_loop_to_header_edge (struct lo
*** 998,1010 ****
  		new_bb->flags |= BB_IRREDUCIBLE_LOOP;
  
  	      FOR_EACH_EDGE (ae, ei, new_bb->succs)
! 		if (ae->dest->rbi->duplicated
  		    && (ae->src->loop_father == target
  			|| ae->dest->loop_father == target))
  		  ae->flags |= EDGE_IRREDUCIBLE_LOOP;
  	    }
  	  for (i = 0; i < n; i++)
! 	    new_bbs[i]->rbi->duplicated = 0;
  	}
  
        /* Redirect the special edges.  */
--- 1001,1013 ----
  		new_bb->flags |= BB_IRREDUCIBLE_LOOP;
  
  	      FOR_EACH_EDGE (ae, ei, new_bb->succs)
! 		if ((ae->dest->flags & BB_DUPLICATED)
  		    && (ae->src->loop_father == target
  			|| ae->dest->loop_father == target))
  		  ae->flags |= EDGE_IRREDUCIBLE_LOOP;
  	    }
  	  for (i = 0; i < n; i++)
! 	    new_bbs[i]->flags &= ~BB_DUPLICATED;
  	}
  
        /* Redirect the special edges.  */
*************** duplicate_loop_to_header_edge (struct lo
*** 1064,1070 ****
        int n_dom_bbs,j;
  
        bb = bbs[i];
!       bb->rbi->copy_number = 0;
  
        n_dom_bbs = get_dominated_by (CDI_DOMINATORS, bb, &dom_bbs);
        for (j = 0; j < n_dom_bbs; j++)
--- 1067,1073 ----
        int n_dom_bbs,j;
  
        bb = bbs[i];
!       bb->aux = 0;
  
        n_dom_bbs = get_dominated_by (CDI_DOMINATORS, bb, &dom_bbs);
        for (j = 0; j < n_dom_bbs; j++)
*************** loop_version (struct loops *loops, struc
*** 1447,1464 ****
        return NULL;
      }
  
!   latch_edge = single_succ_edge (loop->latch->rbi->copy);
    
    extract_cond_bb_edges (*condition_bb, &true_edge, &false_edge);
    nloop = loopify (loops,
  		   latch_edge,
! 		   single_pred_edge (loop->header->rbi->copy),
  		   *condition_bb, true_edge, false_edge,
  		   false /* Do not redirect all edges.  */);
  
    exit = loop->single_exit;
    if (exit)
!     nloop->single_exit = find_edge (exit->src->rbi->copy, exit->dest);
  
    /* loopify redirected latch_edge. Update its PENDING_STMTS.  */ 
    lv_flush_pending_stmts (latch_edge);
--- 1450,1467 ----
        return NULL;
      }
  
!   latch_edge = single_succ_edge (get_bb_copy (loop->latch));
    
    extract_cond_bb_edges (*condition_bb, &true_edge, &false_edge);
    nloop = loopify (loops,
  		   latch_edge,
! 		   single_pred_edge (get_bb_copy (loop->header)),
  		   *condition_bb, true_edge, false_edge,
  		   false /* Do not redirect all edges.  */);
  
    exit = loop->single_exit;
    if (exit)
!     nloop->single_exit = find_edge (get_bb_copy (exit->src), exit->dest);
  
    /* loopify redirected latch_edge. Update its PENDING_STMTS.  */ 
    lv_flush_pending_stmts (latch_edge);
Index: dominance.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dominance.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 dominance.c
*** dominance.c	22 Apr 2005 16:14:52 -0000	1.39
--- dominance.c	31 May 2005 20:19:42 -0000
*************** get_dominated_by_region (enum cdi_direct
*** 746,760 ****
    basic_block dom;
  
    for (i = 0; i < n_region; i++)
!     region[i]->rbi->duplicated = 1;
    for (i = 0; i < n_region; i++)
      for (dom = first_dom_son (dir, region[i]);
  	 dom;
  	 dom = next_dom_son (dir, dom))
!       if (!dom->rbi->duplicated)
  	doms[n_doms++] = dom;
    for (i = 0; i < n_region; i++)
!     region[i]->rbi->duplicated = 0;
  
    return n_doms;
  }
--- 746,760 ----
    basic_block dom;
  
    for (i = 0; i < n_region; i++)
!     region[i]->flags |= BB_DUPLICATED;
    for (i = 0; i < n_region; i++)
      for (dom = first_dom_son (dir, region[i]);
  	 dom;
  	 dom = next_dom_son (dir, dom))
!       if (!(dom->flags & BB_DUPLICATED))
  	doms[n_doms++] = dom;
    for (i = 0; i < n_region; i++)
!     region[i]->flags &= ~BB_DUPLICATED;
  
    return n_doms;
  }
Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/except.c,v
retrieving revision 1.307
diff -c -3 -p -r1.307 except.c
*** except.c	27 May 2005 22:50:41 -0000	1.307
--- except.c	31 May 2005 20:19:43 -0000
*************** expand_resx_expr (tree exp)
*** 572,577 ****
--- 572,578 ----
    int region_nr = TREE_INT_CST_LOW (TREE_OPERAND (exp, 0));
    struct eh_region *reg = cfun->eh->region_array[region_nr];
  
+   gcc_assert (!reg->resume);
    reg->resume = emit_jump_insn (gen_rtx_RESX (VOIDmode, region_nr));
    emit_barrier ();
  }
Index: loop-unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unroll.c,v
retrieving revision 1.33
diff -c -3 -p -r1.33 loop-unroll.c
*** loop-unroll.c	6 May 2005 20:24:00 -0000	1.33
--- loop-unroll.c	31 May 2005 20:19:44 -0000
*************** unroll_loop_constant_iterations (struct 
*** 790,796 ****
  
    if (exit_at_end)
      {
!       basic_block exit_block = desc->in_edge->src->rbi->copy;
        /* Find a new in and out edge; they are in the last copy we have made.  */
        
        if (EDGE_SUCC (exit_block, 0)->dest == desc->out_edge->dest)
--- 790,796 ----
  
    if (exit_at_end)
      {
!       basic_block exit_block = get_bb_copy (desc->in_edge->src);
        /* Find a new in and out edge; they are in the last copy we have made.  */
        
        if (EDGE_SUCC (exit_block, 0)->dest == desc->out_edge->dest)
*************** unroll_loop_runtime_iterations (struct l
*** 1110,1116 ****
  
    if (exit_at_end)
      {
!       basic_block exit_block = desc->in_edge->src->rbi->copy;
        /* Find a new in and out edge; they are in the last copy we have
  	 made.  */
        
--- 1110,1116 ----
  
    if (exit_at_end)
      {
!       basic_block exit_block = get_bb_copy (desc->in_edge->src);
        /* Find a new in and out edge; they are in the last copy we have
  	 made.  */
        
*************** apply_opt_in_copies (struct opt_info *op
*** 2058,2066 ****
    for (i = opt_info->first_new_block; i < (unsigned) last_basic_block; i++)
      {
        bb = BASIC_BLOCK (i);
!       orig_bb = bb->rbi->original;
        
!       delta = determine_split_iv_delta (bb->rbi->copy_number, n_copies,
  					unrolling);
        orig_insn = BB_HEAD (orig_bb);
        for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next)
--- 2058,2068 ----
    for (i = opt_info->first_new_block; i < (unsigned) last_basic_block; i++)
      {
        bb = BASIC_BLOCK (i);
!       orig_bb = get_bb_original (bb);
        
!       /* bb->aux holds position in copy sequence initialized by
! 	 duplicate_loop_to_header_edge.  */
!       delta = determine_split_iv_delta ((size_t)bb->aux, n_copies,
  					unrolling);
        orig_insn = BB_HEAD (orig_bb);
        for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next)
*************** apply_opt_in_copies (struct opt_info *op
*** 2124,2135 ****
    
    /* Rewrite also the original loop body.  Find them as originals of the blocks
       in the last copied iteration, i.e. those that have
!      bb->rbi->original->copy == bb.  */
    for (i = opt_info->first_new_block; i < (unsigned) last_basic_block; i++)
      {
        bb = BASIC_BLOCK (i);
!       orig_bb = bb->rbi->original;
!       if (orig_bb->rbi->copy != bb)
  	continue;
        
        delta = determine_split_iv_delta (0, n_copies, unrolling);
--- 2126,2137 ----
    
    /* Rewrite also the original loop body.  Find them as originals of the blocks
       in the last copied iteration, i.e. those that have
!      get_bb_copy (get_bb_original (bb)) == bb.  */
    for (i = opt_info->first_new_block; i < (unsigned) last_basic_block; i++)
      {
        bb = BASIC_BLOCK (i);
!       orig_bb = get_bb_original (bb);
!       if (get_bb_copy (orig_bb) != bb)
  	continue;
        
        delta = determine_split_iv_delta (0, n_copies, unrolling);
Index: loop-unswitch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unswitch.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 loop-unswitch.c
*** loop-unswitch.c	3 May 2005 13:09:33 -0000	1.30
--- loop-unswitch.c	31 May 2005 20:19:44 -0000
*************** unswitch_loop (struct loops *loops, stru
*** 431,440 ****
    entry->flags |= irred_flag;
  
    /* Record the block with condition we unswitch on.  */
!   unswitch_on_alt = unswitch_on->rbi->copy;
    true_edge = BRANCH_EDGE (unswitch_on_alt);
    false_edge = FALLTHRU_EDGE (unswitch_on);
!   latch_edge = single_succ_edge (loop->latch->rbi->copy);
  
    /* Create a block with the condition.  */
    prob = true_edge->probability;
--- 431,440 ----
    entry->flags |= irred_flag;
  
    /* Record the block with condition we unswitch on.  */
!   unswitch_on_alt = get_bb_copy (unswitch_on);
    true_edge = BRANCH_EDGE (unswitch_on_alt);
    false_edge = FALLTHRU_EDGE (unswitch_on);
!   latch_edge = single_succ_edge (get_bb_copy (loop->latch));
  
    /* Create a block with the condition.  */
    prob = true_edge->probability;
*************** unswitch_loop (struct loops *loops, stru
*** 465,471 ****
  
    /* Loopify from the copy of LOOP body, constructing the new loop.  */
    nloop = loopify (loops, latch_edge,
! 		   single_pred_edge (loop->header->rbi->copy), switch_bb,
  		   BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true);
  
    /* Remove branches that are now unreachable in new loops.  */
--- 465,471 ----
  
    /* Loopify from the copy of LOOP body, constructing the new loop.  */
    nloop = loopify (loops, latch_edge,
! 		   single_pred_edge (get_bb_copy (loop->header)), switch_bb,
  		   BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true);
  
    /* Remove branches that are now unreachable in new loops.  */
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.200
diff -c -3 -p -r2.200 tree-cfg.c
*** tree-cfg.c	28 May 2005 21:09:13 -0000	2.200
--- tree-cfg.c	31 May 2005 20:19:46 -0000
*************** create_bb (void *h, void *e, basic_block
*** 391,397 ****
    n_basic_blocks++;
    last_basic_block++;
  
-   initialize_bb_rbi (bb);
    return bb;
  }
  
--- 391,396 ----
*************** disband_implicit_edges (void)
*** 2557,2567 ****
  void
  delete_tree_cfg_annotations (void)
  {
-   basic_block bb;
- 
    label_to_block_map = NULL;
-   FOR_EACH_BB (bb)
-     bb->rbi = NULL;
  }
  
  
--- 2556,2562 ----
*************** tree_duplicate_bb (basic_block bb)
*** 4144,4150 ****
  
  /* Basic block BB_COPY was created by code duplication.  Add phi node
     arguments for edges going out of BB_COPY.  The blocks that were
!    duplicated have rbi->duplicated set to one.  */
  
  void
  add_phi_args_after_copy_bb (basic_block bb_copy)
--- 4139,4145 ----
  
  /* Basic block BB_COPY was created by code duplication.  Add phi node
     arguments for edges going out of BB_COPY.  The blocks that were
!    duplicated have BB_DUPLICATED set.  */
  
  void
  add_phi_args_after_copy_bb (basic_block bb_copy)
*************** add_phi_args_after_copy_bb (basic_block 
*** 4154,4168 ****
    edge_iterator ei;
    tree phi, phi_copy, phi_next, def;
        
!   bb = bb_copy->rbi->original;
  
    FOR_EACH_EDGE (e_copy, ei, bb_copy->succs)
      {
        if (!phi_nodes (e_copy->dest))
  	continue;
  
!       if (e_copy->dest->rbi->duplicated)
! 	dest = e_copy->dest->rbi->original;
        else
  	dest = e_copy->dest;
  
--- 4149,4163 ----
    edge_iterator ei;
    tree phi, phi_copy, phi_next, def;
        
!   bb = get_bb_original (bb_copy);
  
    FOR_EACH_EDGE (e_copy, ei, bb_copy->succs)
      {
        if (!phi_nodes (e_copy->dest))
  	continue;
  
!       if (e_copy->dest->flags & BB_DUPLICATED)
! 	dest = get_bb_original (e_copy->dest);
        else
  	dest = e_copy->dest;
  
*************** add_phi_args_after_copy_bb (basic_block 
*** 4173,4180 ****
  	     In this case we are not looking for edge to dest, but to
  	     duplicated block whose original was dest.  */
  	  FOR_EACH_EDGE (e, ei, bb->succs)
! 	    if (e->dest->rbi->duplicated
! 		&& e->dest->rbi->original == dest)
  	      break;
  
  	  gcc_assert (e != NULL);
--- 4168,4175 ----
  	     In this case we are not looking for edge to dest, but to
  	     duplicated block whose original was dest.  */
  	  FOR_EACH_EDGE (e, ei, bb->succs)
! 	    if ((e->dest->flags & BB_DUPLICATED)
! 		&& get_bb_original (e->dest) == dest)
  	      break;
  
  	  gcc_assert (e != NULL);
*************** add_phi_args_after_copy (basic_block *re
*** 4201,4213 ****
    unsigned i;
  
    for (i = 0; i < n_region; i++)
!     region_copy[i]->rbi->duplicated = 1;
  
    for (i = 0; i < n_region; i++)
      add_phi_args_after_copy_bb (region_copy[i]);
  
    for (i = 0; i < n_region; i++)
!     region_copy[i]->rbi->duplicated = 0;
  }
  
  /* Duplicates a REGION (set of N_REGION basic blocks) with just a single
--- 4196,4208 ----
    unsigned i;
  
    for (i = 0; i < n_region; i++)
!     region_copy[i]->flags |= BB_DUPLICATED;
  
    for (i = 0; i < n_region; i++)
      add_phi_args_after_copy_bb (region_copy[i]);
  
    for (i = 0; i < n_region; i++)
!     region_copy[i]->flags &= ~BB_DUPLICATED;
  }
  
  /* Duplicates a REGION (set of N_REGION basic blocks) with just a single
*************** tree_duplicate_sese_region (edge entry, 
*** 4281,4286 ****
--- 4276,4283 ----
    /* Record blocks outside the region that are dominated by something
       inside.  */
    doms = xmalloc (sizeof (basic_block) * n_basic_blocks);
+   initialize_original_copy_tables ();
+ 
    n_doms = get_dominated_by_region (CDI_DOMINATORS, region, n_region, doms);
  
    total_freq = entry->dest->frequency;
*************** tree_duplicate_sese_region (edge entry, 
*** 4304,4310 ****
      }
  
    /* Redirect the entry and add the phi node arguments.  */
!   redirected = redirect_edge_and_branch (entry, entry->dest->rbi->copy);
    gcc_assert (redirected != NULL);
    flush_pending_stmts (entry);
  
--- 4301,4307 ----
      }
  
    /* Redirect the entry and add the phi node arguments.  */
!   redirected = redirect_edge_and_branch (entry, get_bb_copy (entry->dest));
    gcc_assert (redirected != NULL);
    flush_pending_stmts (entry);
  
*************** tree_duplicate_sese_region (edge entry, 
*** 4313,4319 ****
       region, but was dominated by something inside needs recounting as
       well.  */
    set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src);
!   doms[n_doms++] = entry->dest->rbi->original;
    iterate_fix_dominators (CDI_DOMINATORS, doms, n_doms);
    free (doms);
  
--- 4310,4316 ----
       region, but was dominated by something inside needs recounting as
       well.  */
    set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src);
!   doms[n_doms++] = get_bb_original (entry->dest);
    iterate_fix_dominators (CDI_DOMINATORS, doms, n_doms);
    free (doms);
  
*************** tree_duplicate_sese_region (edge entry, 
*** 4326,4331 ****
--- 4323,4329 ----
    if (free_region_copy)
      free (region_copy);
  
+   free_original_copy_tables ();
    return true;
  }
  
Index: tree-ssa-loop-ivcanon.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivcanon.c,v
retrieving revision 2.13
diff -c -3 -p -r2.13 tree-ssa-loop-ivcanon.c
*** tree-ssa-loop-ivcanon.c	7 May 2005 14:43:53 -0000	2.13
--- tree-ssa-loop-ivcanon.c	31 May 2005 20:19:48 -0000
*************** try_unroll_loop_completely (struct loops
*** 226,231 ****
--- 226,232 ----
        old_cond = COND_EXPR_COND (cond);
        COND_EXPR_COND (cond) = dont_exit;
        update_stmt (cond);
+       initialize_original_copy_tables ();
  
        if (!tree_duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
  					       loops, n_unroll, NULL,
*************** try_unroll_loop_completely (struct loops
*** 233,240 ****
--- 234,243 ----
  	{
  	  COND_EXPR_COND (cond) = old_cond;
  	  update_stmt (cond);
+           free_original_copy_tables ();
  	  return false;
  	}
+       free_original_copy_tables ();
      }
    
    COND_EXPR_COND (cond) = do_exit;
Index: tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-manip.c,v
retrieving revision 2.32
diff -c -3 -p -r2.32 tree-ssa-loop-manip.c
*** tree-ssa-loop-manip.c	1 May 2005 08:08:06 -0000	2.32
--- tree-ssa-loop-manip.c	31 May 2005 20:19:48 -0000
*************** copy_phi_node_args (unsigned first_new_b
*** 566,578 ****
    unsigned i;
  
    for (i = first_new_block; i < (unsigned) last_basic_block; i++)
!     BASIC_BLOCK (i)->rbi->duplicated = 1;
  
    for (i = first_new_block; i < (unsigned) last_basic_block; i++)
      add_phi_args_after_copy_bb (BASIC_BLOCK (i));
  
    for (i = first_new_block; i < (unsigned) last_basic_block; i++)
!     BASIC_BLOCK (i)->rbi->duplicated = 0;
  }
  
  
--- 566,578 ----
    unsigned i;
  
    for (i = first_new_block; i < (unsigned) last_basic_block; i++)
!     BASIC_BLOCK (i)->flags |= BB_DUPLICATED;
  
    for (i = first_new_block; i < (unsigned) last_basic_block; i++)
      add_phi_args_after_copy_bb (BASIC_BLOCK (i));
  
    for (i = first_new_block; i < (unsigned) last_basic_block; i++)
!     BASIC_BLOCK (i)->flags &= ~BB_DUPLICATED;
  }
  
  
Index: tree-ssa-loop-unswitch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-unswitch.c,v
retrieving revision 2.11
diff -c -3 -p -r2.11 tree-ssa-loop-unswitch.c
*** tree-ssa-loop-unswitch.c	3 May 2005 12:19:46 -0000	2.11
--- tree-ssa-loop-unswitch.c	31 May 2005 20:19:48 -0000
*************** tree_unswitch_single_loop (struct loops 
*** 249,254 ****
--- 249,255 ----
    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, ";; Unswitching loop\n");
  
+   initialize_original_copy_tables ();
    /* Unswitch the loop on this condition.  */
    nloop = tree_unswitch_loop (loops, loop, bbs[i], cond);
    if (!nloop)
*************** tree_unswitch_single_loop (struct loops 
*** 256,261 ****
--- 257,263 ----
  
    /* Update the SSA form after unswitching.  */
    update_ssa (TODO_update_ssa);
+   free_original_copy_tables ();
  
    /* Invoke itself on modified loops.  */
    tree_unswitch_single_loop (loops, nloop, num + 1);


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