This is the mail archive of the gcc@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]

Re: egcs-971031, sparc-sun-solaris2.5 new bootstrap failure


>   > Why not add a new argument to loop_optimize, so that
>   > rest_of_compilation can exactly tell it if there will be an subsequent
>   > loop unrolling.  loop_optimize could then store this information in a
>   > variable static to loop.c .
> Something like this is pretty reasonable for the mainline sources.  Will
> you implement it and send me the diffs?

I have thought about this some more, and have come to the conclusion that
it would be cleaner not to change flag_unroll_loops in
the first place.
There is also no need to manipulate flag_unroll_all_loops - it has only an
effect on unroll_loop, and this function is only called when some loop
unrolling is done in the first place.

Tue Nov 25 22:32:49 1997  J"orn Rennecke <amylaar@cygnus.co.uk>

	* loop.c (invariant_p): Don't test flag_rerun_loop_opt.
	(loop_optimize, scan_loop, strength_reduce): New argument unroll_p.
	* toplev.c (rest_of_compilation): Pass it.  Remove code to
	save / clear / restore flag_unroll_{,all_}loops.

Index: loop.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.20
diff -p -r1.20 loop.c
*** loop.c	1997/11/09 08:35:43	1.20
--- loop.c	1997/11/25 22:34:24
*************** init_loop ()
*** 374,383 ****
     (or 0 if none should be output).  */
  
  void
! loop_optimize (f, dumpfile)
       /* f is the first instruction of a chain of insns for one function */
       rtx f;
       FILE *dumpfile;
  {
    register rtx insn;
    register int i;
--- 374,384 ----
     (or 0 if none should be output).  */
  
  void
! loop_optimize (f, dumpfile, unroll_p)
       /* f is the first instruction of a chain of insns for one function */
       rtx f;
       FILE *dumpfile;
+      int unroll_p;
  {
    register rtx insn;
    register int i;
*************** loop_optimize (f, dumpfile)
*** 502,508 ****
        uid_luid[i] = uid_luid[i - 1];
  
    /* Create a mapping from loops to BLOCK tree nodes.  */
!   if (flag_unroll_loops && write_symbols != NO_DEBUG)
      find_loop_tree_blocks ();
  
    /* Determine if the function has indirect jump.  On some systems
--- 503,509 ----
        uid_luid[i] = uid_luid[i - 1];
  
    /* Create a mapping from loops to BLOCK tree nodes.  */
!   if (unroll_p && write_symbols != NO_DEBUG)
      find_loop_tree_blocks ();
  
    /* Determine if the function has indirect jump.  On some systems
*************** loop_optimize (f, dumpfile)
*** 514,525 ****
    for (i = max_loop_num-1; i >= 0; i--)
      if (! loop_invalid[i] && loop_number_loop_ends[i])
        scan_loop (loop_number_loop_starts[i], loop_number_loop_ends[i],
! 		 max_reg_num ());
  
    /* If debugging and unrolling loops, we must replicate the tree nodes
       corresponding to the blocks inside the loop, so that the original one
       to one mapping will remain.  */
!   if (flag_unroll_loops && write_symbols != NO_DEBUG)
      unroll_block_trees ();
  }
  
--- 515,526 ----
    for (i = max_loop_num-1; i >= 0; i--)
      if (! loop_invalid[i] && loop_number_loop_ends[i])
        scan_loop (loop_number_loop_starts[i], loop_number_loop_ends[i],
! 		 max_reg_num (), unroll_p);
  
    /* If debugging and unrolling loops, we must replicate the tree nodes
       corresponding to the blocks inside the loop, so that the original one
       to one mapping will remain.  */
!   if (unroll_p && write_symbols != NO_DEBUG)
      unroll_block_trees ();
  }
  
*************** loop_optimize (f, dumpfile)
*** 534,542 ****
     write, then we can also mark the memory read as invariant.  */
  
  static void
! scan_loop (loop_start, end, nregs)
       rtx loop_start, end;
       int nregs;
  {
    register int i;
    register rtx p;
--- 535,544 ----
     write, then we can also mark the memory read as invariant.  */
  
  static void
! scan_loop (loop_start, end, nregs, unroll_p)
       rtx loop_start, end;
       int nregs;
+      int unroll_p;
  {
    register int i;
    register rtx p;
*************** scan_loop (loop_start, end, nregs)
*** 1051,1057 ****
  
    if (flag_strength_reduce)
      strength_reduce (scan_start, end, loop_top,
! 		     insn_count, loop_start, end);
  }
  
  /* Add elements to *OUTPUT to record all the pseudo-regs
--- 1053,1059 ----
  
    if (flag_strength_reduce)
      strength_reduce (scan_start, end, loop_top,
! 		     insn_count, loop_start, end, unroll_p);
  }
  
  /* Add elements to *OUTPUT to record all the pseudo-regs
*************** invariant_p (x)
*** 2847,2858 ****
  
  	 We don't know the loop bounds here though, so just fail for all
  	 labels.  */
!       /* ??? This is also necessary if flag_rerun_loop_opt is true, because in
! 	 this case we may be doing loop unrolling the second time we run loop,
! 	 and hence the first loop run also needs this check.  There is no way
! 	 to check here whether the second run will actually do loop unrolling
! 	 though, as that info is in a local var in rest_of_compilation.  */
!       if (flag_unroll_loops || flag_rerun_loop_opt)
  	return 0;
        else
  	return 1;
--- 2849,2855 ----
  
  	 We don't know the loop bounds here though, so just fail for all
  	 labels.  */
!       if (flag_unroll_loops)
  	return 0;
        else
  	return 1;
*************** static rtx addr_placeholder;
*** 3339,3351 ****
  
  static void
  strength_reduce (scan_start, end, loop_top, insn_count,
! 		 loop_start, loop_end)
       rtx scan_start;
       rtx end;
       rtx loop_top;
       int insn_count;
       rtx loop_start;
       rtx loop_end;
  {
    rtx p;
    rtx set;
--- 3336,3349 ----
  
  static void
  strength_reduce (scan_start, end, loop_top, insn_count,
! 		 loop_start, loop_end, unroll_p)
       rtx scan_start;
       rtx end;
       rtx loop_top;
       int insn_count;
       rtx loop_start;
       rtx loop_end;
+      int unroll_p;
  {
    rtx p;
    rtx set;
*************** strength_reduce (scan_start, end, loop_t
*** 3583,3589 ****
      {
        /* Can still unroll the loop anyways, but indicate that there is no
  	 strength reduction info available.  */
!       if (flag_unroll_loops)
  	unroll_loop (loop_end, insn_count, loop_start, end_insert_before, 0);
  
        return;
--- 3581,3587 ----
      {
        /* Can still unroll the loop anyways, but indicate that there is no
  	 strength reduction info available.  */
!       if (unroll_p)
  	unroll_loop (loop_end, insn_count, loop_start, end_insert_before, 0);
  
        return;
*************** strength_reduce (scan_start, end, loop_t
*** 4362,4368 ****
       induction variable information that strength_reduce has already
       collected.  */
    
!   if (flag_unroll_loops)
      unroll_loop (loop_end, insn_count, loop_start, end_insert_before, 1);
  
  #ifdef HAIFA
--- 4360,4366 ----
       induction variable information that strength_reduce has already
       collected.  */
    
!   if (unroll_p)
      unroll_loop (loop_end, insn_count, loop_start, end_insert_before, 1);
  
  #ifdef HAIFA
  
Index: toplev.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.15
diff -p -r1.15 toplev.c
*** toplev.c	1997/11/14 15:44:56	1.15
--- toplev.c	1997/11/25 22:34:29
*************** rest_of_compilation (decl)
*** 3313,3340 ****
      {
        TIMEVAR (loop_time,
  	       {
- 		 int save_flag_unroll_loops;
- 		 int save_flag_unroll_all_loops;
- 
  		 if (flag_rerun_loop_opt)
  		   {
  		      /* We only want to perform unrolling once.  */
- 		      save_flag_unroll_loops = flag_unroll_loops;
- 		      save_flag_unroll_all_loops = flag_unroll_all_loops;
- 		      flag_unroll_loops = 0;
- 		      flag_unroll_all_loops = 0;
  
! 		      loop_optimize (insns, loop_dump_file);
  
  		      /* The regscan pass may not be necessary, but let's
  			 be safe until we can prove otherwise.  */
  		      reg_scan (insns, max_reg_num (), 1);
- 
- 		      /* Restore loop unrolling flags.  */
- 		      flag_unroll_loops = save_flag_unroll_loops;
- 		      flag_unroll_all_loops = save_flag_unroll_all_loops;
  		   }
! 		 loop_optimize (insns, loop_dump_file);
  	       });
      }
  
--- 3313,3329 ----
      {
        TIMEVAR (loop_time,
  	       {
  		 if (flag_rerun_loop_opt)
  		   {
  		      /* We only want to perform unrolling once.  */
  
! 		      loop_optimize (insns, loop_dump_file, 0);
  
  		      /* The regscan pass may not be necessary, but let's
  			 be safe until we can prove otherwise.  */
  		      reg_scan (insns, max_reg_num (), 1);
  		   }
! 		 loop_optimize (insns, loop_dump_file, flag_unroll_loops);
  	       });
      }
  


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