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]

Small loop_optimize call cleanup


Hi
This is small bit I can break out of prefetch changes.
This patch changes the unroll_p and bct_p parameters in scan_loop to flags
similary as we did in other passes.

Sun Apr 30 18:42:11 CEST 2000  Jan Hubicka  <jh@suse.cz>
	* loop.c (scan_loop, strength_reduce, loop_optimize): Change unroll_p
	and bct_p parameters to flags.
	* loop.h (LOOP_UNROLL, LOOP_BCT): New constants.
	* rtl.h (loop_optimize): Update prototype.
	* toplev.c (rest_of_compilation): Update call of loop_optimize.

*** loop.c.old	Sun Apr 30 18:34:19 2000
--- loop.c	Sun Apr 30 18:40:48 2000
*************** static void count_loop_regs_set PARAMS (
*** 246,252 ****
  static void note_addr_stored PARAMS ((rtx, rtx, void *));
  static void note_set_pseudo_multiple_uses PARAMS ((rtx, rtx, void *));
  static int loop_reg_used_before_p PARAMS ((const struct loop *, rtx, rtx));
! static void scan_loop PARAMS ((struct loop*, int, int));
  #if 0
  static void replace_call_address PARAMS ((rtx, rtx, rtx));
  #endif
--- 246,252 ----
  static void note_addr_stored PARAMS ((rtx, rtx, void *));
  static void note_set_pseudo_multiple_uses PARAMS ((rtx, rtx, void *));
  static int loop_reg_used_before_p PARAMS ((const struct loop *, rtx, rtx));
! static void scan_loop PARAMS ((struct loop*, int));
  #if 0
  static void replace_call_address PARAMS ((rtx, rtx, rtx));
  #endif
*************** static void add_label_notes PARAMS ((rtx
*** 261,267 ****
  static void move_movables PARAMS ((struct loop *loop, struct movable *, 
  				   int, int, int));
  static int count_nonfixed_reads PARAMS ((const struct loop *, rtx));
! static void strength_reduce PARAMS ((struct loop *, int, int, int));
  static void find_single_use_in_loop PARAMS ((rtx, rtx, varray_type));
  static int valid_initial_value_p PARAMS ((rtx, rtx, int, rtx));
  static void find_mem_givs PARAMS ((const struct loop *, rtx, rtx, int, int));
--- 261,267 ----
  static void move_movables PARAMS ((struct loop *loop, struct movable *, 
  				   int, int, int));
  static int count_nonfixed_reads PARAMS ((const struct loop *, rtx));
! static void strength_reduce PARAMS ((struct loop *, int, int));
  static void find_single_use_in_loop PARAMS ((rtx, rtx, varray_type));
  static int valid_initial_value_p PARAMS ((rtx, rtx, int, rtx));
  static void find_mem_givs PARAMS ((const struct loop *, rtx, rtx, int, int));
*************** compute_luids (start, end, prev_luid)
*** 417,427 ****
     (or 0 if none should be output).  */
  
  void
! loop_optimize (f, dumpfile, unroll_p, bct_p)
       /* f is the first instruction of a chain of insns for one function */
       rtx f;
       FILE *dumpfile;
!      int unroll_p, bct_p;
  {
    register rtx insn;
    register int i;
--- 417,427 ----
     (or 0 if none should be output).  */
  
  void
! loop_optimize (f, dumpfile, flags)
       /* f is the first instruction of a chain of insns for one function */
       rtx f;
       FILE *dumpfile;
!      int flags;
  {
    register rtx insn;
    register int i;
*************** loop_optimize (f, dumpfile, unroll_p, bc
*** 527,533 ****
        struct loop *loop = &loops->array[i];
  
        if (! loop->invalid && loop->end)
! 	scan_loop (loop, unroll_p, bct_p);
      }
  
    /* If there were lexical blocks inside the loop, they have been
--- 527,533 ----
        struct loop *loop = &loops->array[i];
  
        if (! loop->invalid && loop->end)
! 	scan_loop (loop, flags);
      }
  
    /* If there were lexical blocks inside the loop, they have been
*************** next_insn_in_loop (loop, insn)
*** 586,594 ****
     write, then we can also mark the memory read as invariant.  */
  
  static void
! scan_loop (loop, unroll_p, bct_p)
       struct loop *loop;
!      int unroll_p, bct_p;
  {
    register int i;
    rtx loop_start = loop->start;
--- 586,594 ----
     write, then we can also mark the memory read as invariant.  */
  
  static void
! scan_loop (loop, flags)
       struct loop *loop;
!      int flags;
  {
    register int i;
    rtx loop_start = loop->start;
*************** scan_loop (loop, unroll_p, bct_p)
*** 1140,1146 ****
    if (flag_strength_reduce)
      {
        the_movables = movables;
!       strength_reduce (loop, insn_count, unroll_p, bct_p);
  
        reg_scan_update (update_start, update_end, loop_max_reg);
        loop_max_reg = max_reg_num ();
--- 1140,1146 ----
    if (flag_strength_reduce)
      {
        the_movables = movables;
!       strength_reduce (loop, insn_count, flags);
  
        reg_scan_update (update_start, update_end, loop_max_reg);
        loop_max_reg = max_reg_num ();
*************** for_each_insn_in_loop (loop, fncall)
*** 3853,3862 ****
     But scan_loop must check regnos to make sure they are in bounds.   */
  
  static void
! strength_reduce (loop, insn_count, unroll_p, bct_p)
       struct loop *loop;
       int insn_count;
!      int unroll_p, bct_p ATTRIBUTE_UNUSED;
  {
    rtx p;
    /* Temporary list pointers for traversing loop_iv_list.  */
--- 3853,3862 ----
     But scan_loop must check regnos to make sure they are in bounds.   */
  
  static void
! strength_reduce (loop, insn_count, flags)
       struct loop *loop;
       int insn_count;
!      int flags;
  {
    rtx p;
    /* Temporary list pointers for traversing loop_iv_list.  */
*************** strength_reduce (loop, insn_count, unrol
*** 3956,3962 ****
      {
        /* Can still unroll the loop anyways, but indicate that there is no
  	 strength reduction info available.  */
!       if (unroll_p)
  	unroll_loop (loop, insn_count, end_insert_before, 0);
  
        goto egress;
--- 3956,3962 ----
      {
        /* Can still unroll the loop anyways, but indicate that there is no
  	 strength reduction info available.  */
!       if (flags & LOOP_UNROLL)
  	unroll_loop (loop, insn_count, end_insert_before, 0);
  
        goto egress;
*************** strength_reduce (loop, insn_count, unrol
*** 4633,4639 ****
  	  VARRAY_GROW (reg_iv_type, nregs);
  	  VARRAY_GROW (reg_iv_info, nregs);
  	}
!       recombine_givs (loop, bl, unroll_p);
  
        /* Reduce each giv that we decided to reduce.  */
  
--- 4633,4639 ----
  	  VARRAY_GROW (reg_iv_type, nregs);
  	  VARRAY_GROW (reg_iv_info, nregs);
  	}
!       recombine_givs (loop, bl, flags & LOOP_UNROLL);
  
        /* Reduce each giv that we decided to reduce.  */
  
*************** strength_reduce (loop, insn_count, unrol
*** 5027,5040 ****
       induction variable information that strength_reduce has already
       collected.  Always unroll loops that would be as small or smaller
       unrolled than when rolled.  */
!   if (unroll_p
        || (loop_info->n_iterations > 0
  	  && unrolled_insn_copies <= insn_count))
      unroll_loop (loop, insn_count, end_insert_before, 1);
  
  #ifdef HAVE_decrement_and_branch_on_count
    /* Instrument the loop with BCT insn.  */
!   if (HAVE_decrement_and_branch_on_count && bct_p
        && flag_branch_on_count_reg)
      insert_bct (loop);
  #endif  /* HAVE_decrement_and_branch_on_count */
--- 5027,5040 ----
       induction variable information that strength_reduce has already
       collected.  Always unroll loops that would be as small or smaller
       unrolled than when rolled.  */
!   if ((flags & LOOP_UNROLL)
        || (loop_info->n_iterations > 0
  	  && unrolled_insn_copies <= insn_count))
      unroll_loop (loop, insn_count, end_insert_before, 1);
  
  #ifdef HAVE_decrement_and_branch_on_count
    /* Instrument the loop with BCT insn.  */
!   if (HAVE_decrement_and_branch_on_count && (flags & LOOP_BCT)
        && flag_branch_on_count_reg)
      insert_bct (loop);
  #endif  /* HAVE_decrement_and_branch_on_count */
*** loop.h.old	Sun Apr 30 18:34:23 2000
--- loop.h	Sun Apr 30 18:35:28 2000
*************** Boston, MA 02111-1307, USA.  */
*** 20,25 ****
--- 20,29 ----
  
  #include "varray.h"
  #include "basic-block.h"
+ /* Flags passed to loop_optimize.  */
+ #define LOOP_UNROLL 1
+ #define LOOP_BCT 2
+ 
  
  /* Get the loop info pointer of a loop.  */
  #define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux) 
*** rtl.h.old	Sun Apr 30 18:35:40 2000
--- rtl.h	Sun Apr 30 18:35:48 2000
*************** extern void print_inline_rtx		PARAMS ((F
*** 1601,1607 ****
  extern void init_loop			PARAMS ((void));
  extern rtx libcall_other_reg		PARAMS ((rtx, rtx));
  #ifdef BUFSIZ
! extern void loop_optimize		PARAMS ((rtx, FILE *, int, int));
  #endif
  extern void record_excess_regs		PARAMS ((rtx, rtx, rtx *));
  
--- 1601,1607 ----
  extern void init_loop			PARAMS ((void));
  extern rtx libcall_other_reg		PARAMS ((rtx, rtx));
  #ifdef BUFSIZ
! extern void loop_optimize		PARAMS ((rtx, FILE *, int));
  #endif
  extern void record_excess_regs		PARAMS ((rtx, rtx, rtx *));
  
*** toplev.c.old	Sun Apr 30 18:34:26 2000
--- toplev.c	Sun Apr 30 18:36:27 2000
*************** rest_of_compilation (decl)
*** 2998,3004 ****
  	{
  	  /* We only want to perform unrolling once.  */
  	       
! 	  loop_optimize (insns, rtl_dump_file, 0, 0);
  
  	  /* The first call to loop_optimize makes some instructions
  	     trivially dead.  We delete those instructions now in the
--- 2998,3004 ----
  	{
  	  /* We only want to perform unrolling once.  */
  	       
! 	  loop_optimize (insns, rtl_dump_file, 0);
  
  	  /* The first call to loop_optimize makes some instructions
  	     trivially dead.  We delete those instructions now in the
*************** rest_of_compilation (decl)
*** 3010,3016 ****
  		  analysis code depends on this information.  */
  	  reg_scan (insns, max_reg_num (), 1);
  	}
!       loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
  
        close_dump_file (DFI_loop, print_rtl, insns);
        timevar_pop (TV_LOOP);
--- 3010,3016 ----
  		  analysis code depends on this information.  */
  	  reg_scan (insns, max_reg_num (), 1);
  	}
!       loop_optimize (insns, rtl_dump_file, (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
  
        close_dump_file (DFI_loop, print_rtl, insns);
        timevar_pop (TV_LOOP);

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