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]
Other format: [Raw text]

Re: rtlopt loop unroller question


Hello,

> >             addi r4,r12,4
> >            addi r2,r12,8
> >            addi r29,r12,12
> >            addi r28,r12,16
> >            addi r27,r12,20
> >            addi r26,r12,24
> >            addi r25,r12,28
> 
> Finally, we still get redundant adds (compared to old-unroll); can
> something be
> done to fix them too?

you may try the following patch; it reduces the compile time to something
more reasonable.

Zdenek

Index: loop-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-init.c,v
retrieving revision 1.1.2.10
diff -c -3 -p -r1.1.2.10 loop-init.c
*** loop-init.c	25 Jul 2003 17:45:00 -0000	1.1.2.10
--- loop-init.c	23 Oct 2003 20:26:29 -0000
*************** loop_optimizer_optimize (struct loops *l
*** 179,184 ****
--- 179,208 ----
    if (flag_peel_loops || flag_unroll_loops)
      unroll_and_peel_loops (loops);
  
+   /* Rerun the optimization again, to improve the induction variable usage in
+      the unrolled loops.  */
+   if (optimize >= 3 && flag_unroll_loops)
+     {
+       timevar_push (TV_IV_ANAL);
+       initialize_iv_analysis (loops);
+       analyse_induction_variables ();
+       timevar_pop (TV_IV_ANAL);
+ 
+       loop_avail_regs = xcalloc (loops->num, sizeof (int));
+       ivopt_actions.ivs = NULL;
+       ivopt_actions.replacements = NULL;
+       ivopt_actions.repl_final_value = NULL;
+       if (flag_strength_reduce)
+ 	detect_strength_reductions (loops, &ivopt_actions);
+       free (loop_avail_regs);
+ 
+       timevar_push (TV_IV_ANAL);
+       finalize_iv_analysis ();
+       timevar_pop (TV_IV_ANAL);
+   
+       execute_strength_reductions (loops, &ivopt_actions);
+     }
+ 
  #ifdef HAVE_doloop_end
    if (HAVE_doloop_end && flag_branch_on_count_reg)
      doloop_optimize_loops (loops);
Index: loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/loop-ivopts.c,v
retrieving revision 1.1.2.10
diff -c -3 -p -r1.1.2.10 loop-ivopts.c
*** loop-ivopts.c	27 Jul 2003 11:27:38 -0000	1.1.2.10
--- loop-ivopts.c	23 Oct 2003 20:26:29 -0000
*************** Software Foundation, 59 Temple Place - S
*** 38,43 ****
--- 38,44 ----
  #include "insn-config.h"
  #include "recog.h"
  #include "regs.h"
+ #include "timevar.h"
  
  #define EL_RTX
  #include "algebraic.h"
*************** detect_strength_reductions (struct loops
*** 350,356 ****
  		afvrepl = kill_old_global_iv (loop, occ, &loop_fvrepls);
  		add_iv_elimination (loop, occ, arepl, afvrepl, &loop_reds);
  	      }
- 
        remove_incorrect_eliminations (loop, &loop_reds, loop_repls);
  
        determine_reductions_to_perform (loop, &loop_reds, loop_repls);
--- 351,356 ----
*************** determine_reductions_to_perform (struct 
*** 2483,2495 ****
        for (red = *reds, nivs = 0; red; red = red->next)
  	nivs++;
  
!       if (nivs > MANY_IVS)
! 	{
! 	  while (decrease_by_one_iv (*reds, repls, loop_avail_regs[loop->num]))
! 	    continue;
! 	}
!       else
  	{
  	  rarray = xmalloc (nivs * sizeof (struct str_red *));
  	  for (red = *reds, nivs = 0; red; red = red->next)
  	    {
--- 2483,2495 ----
        for (red = *reds, nivs = 0; red; red = red->next)
  	nivs++;
  
!       /* First optimize in a greedy fashion.  */
!       while (decrease_by_one_iv (*reds, repls, loop_avail_regs[loop->num]))
! 	continue;
! 
!       if (nivs <= MANY_IVS)
  	{
+ 	  /* Try optimizing the rest of ivs now.  */
  	  rarray = xmalloc (nivs * sizeof (struct str_red *));
  	  for (red = *reds, nivs = 0; red; red = red->next)
  	    {


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