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]

[PATCH]: Cleaning rtl loop walking, take 2


This one was bootstrapped and regtested on i686-pc-linux-gnu.
No regressions.

pre-approved by Roger Sayle on IRC.

Committed to mainline.

2005-03-05  Daniel Berlin  <dberlin@dberlin.org>

	* bb-reorder.c (mark_bb_for_unlikely_executed_section):
	Use FOR_BB_INSNS.
  	* bt-load.c (compute_defs_uses_and_gen): Ditto.
	(link_btr_uses): Ditto.
	* cfgcleanup.c (thread_jump): Ditto.
	* cfgrtl.c (rtl_dump_bb): Ditto.
	(rtl_verify_flow_info_1): Ditto.
	* ddg.c (create_ddg): Ditto.
	* flow.c (delete_noop_moves): Ditto
	(clear_log_links): Ditto.
	* gcse.c (compute_store_table): Ditto.
	* global.c (calculate_local_reg_bb_info): Ditto.
	* local-alloc.c (update_equiv_regs): Ditto.
	* loop-doloop.c (doloop_valid_p): Ditto.
	* loop-unroll.c (apply_opt_in_copies): Ditto.
	* predict.c (estimate_probability): Ditto.
	(expensive_function_p): Ditto.
	* var-tracking.c (prologue_stack_adjust): Ditto.
	(vt_initialize): Ditto.

Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.92
diff -u -p -r1.92 bb-reorder.c
--- bb-reorder.c	25 Feb 2005 07:13:25 -0000	1.92
+++ bb-reorder.c	5 Mar 2005 21:56:22 -0000
@@ -1336,8 +1336,7 @@ mark_bb_for_unlikely_executed_section (b
   
   /* Insert new NOTE immediately after  BASIC_BLOCK note.  */
 
-  for (cur_insn = BB_HEAD (bb); cur_insn != NEXT_INSN (BB_END (bb));
-       cur_insn = NEXT_INSN (cur_insn))
+  FOR_BB_INSNS (bb, cur_insn)
     if (GET_CODE (cur_insn) == NOTE
 	&& NOTE_LINE_NUMBER (cur_insn) == NOTE_INSN_BASIC_BLOCK)
       {
Index: bt-load.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bt-load.c,v
retrieving revision 2.32
diff -u -p -r2.32 bt-load.c
--- bt-load.c	17 Feb 2005 22:41:31 -0000	2.32
+++ bt-load.c	5 Mar 2005 21:56:22 -0000
@@ -465,7 +465,6 @@ compute_defs_uses_and_gen (fibheap_t all
       int reg;
       btr_def defs_this_bb = NULL;
       rtx insn;
-      rtx last;
       int can_throw = 0;
 
       info.users_this_bb = NULL;
@@ -478,10 +477,8 @@ compute_defs_uses_and_gen (fibheap_t all
 	if (TEST_HARD_REG_BIT (all_btrs, reg)
 	    && REGNO_REG_SET_P (bb->global_live_at_start, reg))
 	  SET_HARD_REG_BIT (info.btrs_live_in_block, reg);
-
-      for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb));
-	   insn != last;
-	   insn = NEXT_INSN (insn), insn_luid++)
+      
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (INSN_P (insn))
 	    {
@@ -556,6 +553,7 @@ compute_defs_uses_and_gen (fibheap_t all
 		    }
 		}
 	    }
+	  insn_luid++;
 	}
 
       COPY_HARD_REG_SET (btrs_live[i], info.btrs_live_in_block);
@@ -657,12 +655,9 @@ link_btr_uses (btr_def *def_array, btr_u
     {
       basic_block bb = BASIC_BLOCK (i);
       rtx insn;
-      rtx last;
 
       sbitmap_union_of_preds (reaching_defs, bb_out, i);
-      for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb));
-	   insn != last;
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (INSN_P (insn))
 	    {
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.141
diff -u -p -r1.141 cfgcleanup.c
--- cfgcleanup.c	17 Feb 2005 16:19:27 -0000	1.141
+++ cfgcleanup.c	5 Mar 2005 21:56:23 -0000
@@ -336,8 +336,7 @@ thread_jump (int mode, edge e, basic_blo
 
   /* Short circuit cases where block B contains some side effects, as we can't
      safely bypass it.  */
-  for (insn = NEXT_INSN (BB_HEAD (b)); insn != NEXT_INSN (BB_END (b));
-       insn = NEXT_INSN (insn))
+  FOR_BB_INSNS (b, insn)
     if (INSN_P (insn) && side_effects_p (PATTERN (insn)))
       {
 	BB_SET_FLAG (b, BB_NONTHREADABLE_BLOCK);
Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.159
diff -u -p -r1.159 cfgrtl.c
--- cfgrtl.c	28 Feb 2005 18:18:21 -0000	1.159
+++ cfgrtl.c	5 Mar 2005 21:56:23 -0000
@@ -1784,7 +1784,6 @@ static void
 rtl_dump_bb (basic_block bb, FILE *outf, int indent)
 {
   rtx insn;
-  rtx last;
   char *s_indent;
 
   s_indent = alloca ((size_t) indent + 1);
@@ -1795,8 +1794,7 @@ rtl_dump_bb (basic_block bb, FILE *outf,
   dump_regset (bb->global_live_at_start, outf);
   putc ('\n', outf);
 
-  for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb)); insn != last;
-       insn = NEXT_INSN (insn))
+  FOR_BB_INSNS (bb, insn)
     print_rtl_single (outf, insn);
 
   fprintf (outf, ";;%s Registers live at end: ", s_indent);
@@ -2077,7 +2075,7 @@ rtl_verify_flow_info_1 (void)
 	  err = 1;
 	}
 
-      for (x = BB_HEAD (bb); x != NEXT_INSN (BB_END (bb)); x = NEXT_INSN (x))
+      FOR_BB_INSNS (bb, x)
 	/* We may have a barrier inside a basic block before dead code
 	   elimination.  There is no BLOCK_FOR_INSN field in a barrier.  */
 	if (!BARRIER_P (x) && BLOCK_FOR_INSN (x) != bb)
Index: ddg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ddg.c,v
retrieving revision 1.11
diff -u -p -r1.11 ddg.c
--- ddg.c	22 Nov 2004 12:23:47 -0000	1.11
+++ ddg.c	5 Mar 2005 21:56:23 -0000
@@ -443,8 +443,7 @@ create_ddg (basic_block bb, struct df *d
   g->closing_branch_deps = closing_branch_deps;
 
   /* Count the number of insns in the BB.  */
-  for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
-       insn = NEXT_INSN (insn))
+  FOR_BB_INSNS (bb, insn)
     {
       if (! INSN_P (insn) || GET_CODE (PATTERN (insn)) == USE)
 	continue;
@@ -469,8 +468,8 @@ create_ddg (basic_block bb, struct df *d
   g->closing_branch = NULL;
   i = 0;
   first_note = NULL_RTX;
-  for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
-       insn = NEXT_INSN (insn))
+
+  FOR_BB_INSNS (bb, insn)
     {
       if (! INSN_P (insn))
 	{
Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.620
diff -u -p -r1.620 flow.c
--- flow.c	21 Feb 2005 19:47:40 -0000	1.620
+++ flow.c	5 Mar 2005 21:56:24 -0000
@@ -772,15 +772,14 @@ free_basic_block_vars (void)
 int
 delete_noop_moves (void)
 {
-  rtx insn, next;
+  rtx insn;
   basic_block bb;
   int nnoops = 0;
 
   FOR_EACH_BB (bb)
     {
-      for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next)
+      FOR_BB_INSNS (bb, insn)
 	{
-	  next = NEXT_INSN (insn);
 	  if (INSN_P (insn) && noop_move_p (insn))
 	    {
 	      rtx note;
@@ -4451,8 +4450,7 @@ clear_log_links (sbitmap blocks)
       {
 	basic_block bb = BASIC_BLOCK (i);
 
-	for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
-	     insn = NEXT_INSN (insn))
+	FOR_BB_INSNS (bb, insn)
 	  if (INSN_P (insn))
 	    free_INSN_LIST_list (&LOG_LINKS (insn));
       });
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.336
diff -u -p -r1.336 gcse.c
--- gcse.c	4 Mar 2005 03:14:42 -0000	1.336
+++ gcse.c	5 Mar 2005 21:56:26 -0000
@@ -5677,9 +5677,7 @@ compute_store_table (void)
       /* First compute the registers set in this block.  */
       regvec = last_set_in;
 
-      for (insn = BB_HEAD (bb);
-	   insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (! INSN_P (insn))
 	    continue;
@@ -5702,9 +5700,7 @@ compute_store_table (void)
       /* Now find the stores.  */
       memset (already_set, 0, sizeof (int) * max_gcse_regno);
       regvec = already_set;
-      for (insn = BB_HEAD (bb);
-	   insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (! INSN_P (insn))
 	    continue;
Index: global.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.123
diff -u -p -r1.123 global.c
--- global.c	17 Feb 2005 22:41:32 -0000	1.123
+++ global.c	5 Mar 2005 21:56:26 -0000
@@ -2230,14 +2230,13 @@ static void
 calculate_local_reg_bb_info (void)
 {
   basic_block bb;
-  rtx insn, bound;
+  rtx insn;
 
   VARRAY_INT_INIT (earlyclobber_regclass, 20,
 		   "classes of registers early clobbered in an insn");
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  {
 	    note_stores (PATTERN (insn), mark_reg_change, bb);
Index: local-alloc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/local-alloc.c,v
retrieving revision 1.144
diff -u -p -r1.144 local-alloc.c
--- local-alloc.c	16 Dec 2004 16:48:23 -0000	1.144
+++ local-alloc.c	5 Mar 2005 21:56:27 -0000
@@ -784,9 +784,7 @@ update_equiv_regs (void)
     {
       loop_depth = bb->loop_depth;
 
-      for (insn = BB_HEAD (bb);
-	   insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  rtx note;
 	  rtx set;
@@ -1000,9 +998,7 @@ update_equiv_regs (void)
   FOR_EACH_BB_REVERSE (bb)
     {
       loop_depth = bb->loop_depth;
-      for (insn = BB_END (bb);
-	   insn != PREV_INSN (BB_HEAD (bb));
-	   insn = PREV_INSN (insn))
+      FOR_BB_INSNS_REVERSE (bb, insn)
 	{
 	  rtx link;
 
Index: loop-doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-doloop.c,v
retrieving revision 2.11
diff -u -p -r2.11 loop-doloop.c
--- loop-doloop.c	8 Oct 2004 13:09:56 -0000	2.11
+++ loop-doloop.c	5 Mar 2005 21:56:27 -0000
@@ -183,9 +183,7 @@ doloop_valid_p (struct loop *loop, struc
     {
       bb = body[i];
 
-      for (insn = BB_HEAD (bb);
-	   insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  /* A called function may clobber any special registers required for
 	     low-overhead looping.  */
Index: loop-unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unroll.c,v
retrieving revision 1.26
diff -u -p -r1.26 loop-unroll.c
--- loop-unroll.c	2 Mar 2005 14:03:36 -0000	1.26
+++ loop-unroll.c	5 Mar 2005 21:56:27 -0000
@@ -2025,7 +2025,7 @@ apply_opt_in_copies (struct opt_info *op
 {
   unsigned i, delta;
   basic_block bb, orig_bb;
-  rtx insn, orig_insn, next;
+  rtx insn, orig_insn;
   struct iv_to_split ivts_templ, *ivts;
   struct var_to_expand ve_templ, *ves;
   
@@ -2045,9 +2045,8 @@ apply_opt_in_copies (struct opt_info *op
       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)
+      FOR_BB_INSNS (bb, insn)
         {
-          next = NEXT_INSN (insn);
           if (!INSN_P (insn))
             continue;
           
@@ -2115,12 +2114,8 @@ apply_opt_in_copies (struct opt_info *op
 	continue;
       
       delta = determine_split_iv_delta (0, n_copies, unrolling);
-      for (orig_insn = BB_HEAD (orig_bb);
-           orig_insn != NEXT_INSN (BB_END (bb));
-           orig_insn = next)
+      FOR_BB_INSNS (orig_bb, orig_insn)
         {
-          next = NEXT_INSN (orig_insn);
-          
           if (!INSN_P (orig_insn))
  	    continue;
           
Index: predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.140
diff -u -p -r1.140 predict.c
--- predict.c	1 Mar 2005 13:44:45 -0000	1.140
+++ predict.c	5 Mar 2005 21:56:27 -0000
@@ -850,8 +850,7 @@ estimate_probability (struct loops *loop
 		 is improbable.  This is because such calls are often used
 		 to signal exceptional situations such as printing error
 		 messages.  */
-	      for (insn = BB_HEAD (e->dest); insn != NEXT_INSN (BB_END (e->dest));
-		   insn = NEXT_INSN (insn))
+	      FOR_BB_INSNS (e->dest, insn)
 		if (CALL_P (insn)
 		    /* Constant and pure calls are hardly used to signalize
 		       something exceptional.  */
@@ -1773,8 +1772,7 @@ expensive_function_p (int threshold)
     {
       rtx insn;
 
-      for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (active_insn_p (insn))
 	  {
 	    sum += bb->frequency;
Index: var-tracking.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/var-tracking.c,v
retrieving revision 2.26
diff -u -p -r2.26 var-tracking.c
--- var-tracking.c	27 Jan 2005 09:28:43 -0000	2.26
+++ var-tracking.c	5 Mar 2005 21:56:28 -0000
@@ -495,13 +495,11 @@ prologue_stack_adjust (void)
   HOST_WIDE_INT offset = 0;
   basic_block bb = ENTRY_BLOCK_PTR->next_bb;
   rtx insn;
-  rtx end;
 
   if (!BB_END (bb))
     return 0;
 
-  end = NEXT_INSN (BB_END (bb));
-  for (insn = BB_HEAD (bb); insn != end; insn = NEXT_INSN (insn))
+  FOR_BB_INSNS (bb, insn)
     {
       if (NOTE_P (insn)
 	  && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
@@ -2578,8 +2576,7 @@ vt_initialize (void)
 
       /* Count the number of micro operations.  */
       VTI (bb)->n_mos = 0;
-      for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (INSN_P (insn))
 	    {
@@ -2602,8 +2599,7 @@ vt_initialize (void)
       VTI (bb)->mos = xmalloc (VTI (bb)->n_mos
 			       * sizeof (struct micro_operation_def));
       VTI (bb)->n_mos = 0;
-      for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
-	   insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (INSN_P (insn))
 	    {

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