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]

[cfg-branch]: Print reasons for unrolling/unswitching/peeling todump file


It's always nice to know *why* something happened or didn't, without
having to try to discern it from RTL.
0 functional changes.

2002-03-22  Daniel Berlin  <dan@dberlin.org>

	* unroll-new.c (unroll_loop_constant_iterations): Print out
	reasons for not unrolling/if we unrolled succesfully, to
	rtl_dump_file.
	(unroll_loop_runtime_iterations): Ditto.
	(unroll_simple_loop): Ditto.
	(peel_loop): Ditto for peeling.
	* loop-new.c (unswitch_loop): Ditto for unswitching.
Index: unroll-new.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/unroll-new.c,v
retrieving revision 1.1.2.1
diff -c -3 -p -w -B -b -r1.1.2.1 unroll-new.c
*** unroll-new.c	2002/03/18 20:44:14	1.1.2.1
--- unroll-new.c	2002/03/23 01:08:15
*************** Software Foundation, 59 Temple Place - S
*** 40,45 ****
--- 40,46 ----
  #include "cfglayout.h"
  #include "loop.h"
  #include "params.h"
+ #include "output.h"
  
  static basic_block simple_exit PARAMS ((struct loops *, struct loop *, basic_block *, int *));
  static bool simple_condition_p PARAMS ((struct loop *, basic_block *, rtx, struct loop_desc *));
*************** simple_increment (loops, loop, body, des
*** 246,251 ****
--- 247,254 ----
  
    /* mod_insn must be a simple increment/decrement.  */
    set = single_set (mod_insn);
+   if (!set)
+     return NULL;
    if (!rtx_equal_p (SET_DEST (set), desc->var))
      return NULL;
  
*************** unroll_loop_constant_iterations (loops, 
*** 452,458 ****
--- 455,465 ----
  
    /* Normalization.  */
    if (!count_loop_iterations (desc, &niter, NULL))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unrolling loop, can't count loop iterations\n");
        return 0;
+     }  
  
    if (niter < 0)
      {
*************** unroll_loop_constant_iterations (loops, 
*** 488,493 ****
--- 495,503 ----
  	DLTHE_FLAG_ALL))
      abort ();
  
+   if (rtl_dump_file)
+     fprintf (rtl_dump_file, ";; Unrolling loop\n");
+   
    return 1;
  }
  
*************** unroll_loop_runtime_iterations (loops, l
*** 514,519 ****
--- 524,531 ----
    start_sequence ();
    if (!count_loop_iterations (desc, NULL, &niter))
      {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unrolling loop, can't count loop iterations\n");      
        end_sequence ();
        return 0;
      }
*************** unroll_loop_runtime_iterations (loops, l
*** 613,618 ****
--- 625,633 ----
  	 DLTHE_FLAG_ALL))
      abort ();
  
+   if (rtl_dump_file)
+     fprintf (rtl_dump_file, ";; Unrolling loop");
+   
    return 1;
  }
  
*************** unroll_simple_loop (loops, loop, max_unr
*** 626,632 ****
--- 641,651 ----
       struct loop_desc *desc;
  {
    if (!can_duplicate_loop_p (loop))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unrolling loop, can't duplicate\n");
        return 0;
+     }
  
    switch (desc->cond)
      {
*************** unroll_simple_loop (loops, loop, max_unr
*** 634,639 ****
--- 653,660 ----
        case GTU:
        case LEU:
        case LTU:
+ 	if (rtl_dump_file)
+ 	  fprintf (rtl_dump_file, ";;  Not unrolling loop, GEU/GTU/LEU/LTU condition\n");
  	/* I'm not brave enough to cope with this.  */
  	return 0;
        default:
*************** peel_loop (loops, loop, will_unroll)
*** 666,682 ****
--- 687,716 ----
  
    /* Do not peel cold areas.  */
    if (!maybe_hot_bb_p (loop->header))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not peeling loop, header is cold area\n");
        return 1;
+     }
  
    /* Only peel innermost loops.  */
    if (loop->inner)
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not peeling loop, not innermost loop\n");
        return 1;
+     }
        
    /* Do not peel loops that roll too much.  */
    niter = expected_loop_iterations (loop);
    if (niter > 2 * PARAM_VALUE (MAX_PEEL_TIMES))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not peeling loop, rolls too much (%d iterations > %d [2 * maximum peelings])\n", niter, 2 * PARAM_VALUE (MAX_PEEL_TIMES));    
        return 1;
+     }
    
+ 
    ninsns = num_loop_insns (loop);
  
    npeel = PARAM_VALUE (MAX_PEELED_INSNS) / ninsns - 1;
*************** peel_loop (loops, loop, will_unroll)
*** 690,702 ****
--- 724,746 ----
        /* Do not peel simple loops if also unrolling will be done, not to
  	 interfere with it.  */
        if (will_unroll && simple_loop_p (loops, loop, &desc))
+ 	{
+ 	  if (rtl_dump_file)
+ 	    fprintf (rtl_dump_file, ";; Not peeling loop, loop will be unrolled\n");
  	  return 1;
+ 	}
        
        for (e = loop->header->pred; e->src == loop->latch; e = e->pred_next);
        if (!duplicate_loop_to_header_edge (loop, e, loops, npeel, 0,
  	     DLTHE_FLAG_ALL))
+ 	{
+ 	  if (rtl_dump_file)
+ 	    fprintf (rtl_dump_file, ";; Peeling succesful\n");
  	  return 0;
  	}
+     }
+   if (rtl_dump_file)
+     fprintf (rtl_dump_file, ";; Peeling unsuccessful\n");
    return 1;
  }
  
*************** unroll_loop_new (loops, loop, unroll_all
*** 712,718 ****
--- 756,766 ----
  
    /* Do not unroll cold areas.  */
    if (!maybe_hot_bb_p (loop->header))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unrolling loop, cold area\n");
        return 1;
+     }
  
    ninsns = num_loop_insns (loop);
  
*************** unroll_loop_new (loops, loop, unroll_all
*** 728,749 ****
--- 776,812 ----
  	{
  	  /* Simple for loop.  */
  	  if (unroll_simple_loop (loops, loop, nunroll, &desc))
+ 	    {
+ 	      if (rtl_dump_file)
+ 		fprintf (rtl_dump_file, ";; Unrolling simple for loop unsuccessful\n");
  	      return 1;
  	    }
+ 	}
    
        if (unroll_all)
  	{
  	  /* Do not unroll loops that do not roll.  */
  	  niter = expected_loop_iterations (loop);
  	  if (niter < 2 * PARAM_VALUE (MAX_UNROLL_TIMES))
+ 	    {
+ 	      if (rtl_dump_file)
+ 		fprintf (rtl_dump_file, ";; Not unrolling loop, doesn't roll\n");
  	      return 1;
+ 	    }
  
  	  /* Some hard case; try stupid unrolling anyway.  */
  	  for (e = loop->header->pred; e->src != loop->latch; e = e->pred_next);
  	  if (!duplicate_loop_to_header_edge (loop, e, loops, nunroll, 0,
  		   DLTHE_FLAG_ALL))
+ 	    {
+ 	      if (rtl_dump_file)
+ 		fprintf (rtl_dump_file, ";;  Not unrolling loop, can't duplicate\n");
  	      return 0;
  	    }
+ 	  
+ 	}
      }  
+   if (rtl_dump_file)
+     fprintf (rtl_dump_file, ";; Unrolled loop %d times\n", nunroll);
    return 1;
  }
Index: loop-new.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/loop-new.c,v
retrieving revision 1.1.2.8
diff -c -3 -p -w -B -b -r1.1.2.8 loop-new.c
*** loop-new.c	2002/03/18 20:44:12	1.1.2.8
--- loop-new.c	2002/03/23 01:08:15
*************** Software Foundation, 59 Temple Place - S
*** 41,47 ****
  #include "cfglayout.h"
  #include "loop.h"
  #include "params.h"
! 
  /* Stupid definitions of dominator manipulation.  */
  
  basic_block
--- 41,47 ----
  #include "cfglayout.h"
  #include "loop.h"
  #include "params.h"
! #include "output.h"
  /* Stupid definitions of dominator manipulation.  */
  
  basic_block
*************** unswitch_single_loop (loops, loop, cond_
*** 459,485 ****
--- 459,509 ----
  
    /* Do not unswitch too much.  */
    if (num > PARAM_VALUE (MAX_UNSWITCH_LEVEL))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unswitching anymore, hit max level\n");
        return;
+     }
  
    /* We only unswitch innermost loops (at least for now).  */
    if (loop->inner)
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unswitching, not innermost loop\n");
        return;
+     }
    
    /* And we must be able to duplicate loop body.  */
    if (!can_duplicate_loop_p (loop))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unswitching, can't duplicate loop\n");
        return;
+     }
  
    /* Check the size of loop.  */
    if (num_loop_insns (loop) > PARAM_VALUE (MAX_UNSWITCH_INSNS))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unswitching, loop too big\n");
        return;
+     }
    
    /* Do not unswitch in cold areas.  */
    if (!maybe_hot_bb_p (loop->header))
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unswitching, not hot area\n");
        return;
+     }
    
    /* Nor if it usually do not pass.  */
    if (expected_loop_iterations (loop) < 1)
+     {
+       if (rtl_dump_file)
+ 	fprintf (rtl_dump_file, ";; Not unswitching, loop iterations < 1\n");
        return;
+     }
  
    do
      {
*************** unswitch_single_loop (loops, loop, cond_
*** 557,563 ****
    bb = split_loop_bb (loops, bbs[i], PREV_INSN (bbs[i]->end))->dest;
    free (bbs);
    true_first = !(bb->succ->flags & EDGE_FALLTHRU);
! 
    /* Unswitch the loop.  */
    nloop = unswitch_loop (loops, loop, bb);
    if (!nloop)
--- 581,588 ----
    bb = split_loop_bb (loops, bbs[i], PREV_INSN (bbs[i]->end))->dest;
    free (bbs);
    true_first = !(bb->succ->flags & EDGE_FALLTHRU);
!   if (rtl_dump_file)
!     fprintf (rtl_dump_file, ";; Unswitching loop\n");
    /* Unswitch the loop.  */
    nloop = unswitch_loop (loops, loop, bb);
    if (!nloop)


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