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: Loop optimization bug with Ada front end on PPC (and probably Alpha)


On Tue, Nov 27, 2001 at 03:26:43PM -0600, Corey Minyard wrote:
> Are you moving back to the original loop test?  I think the original 
> test you had didn't work because it wasn't the doloop case, but if you 
> put it in the doloop code it should work properly.

I'm taking out the CONT test, yes.  But I'm keeping the LUID
test against the BIV initializer rather than scanning with
reg_set_between_p.


r~


Index: doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.12
diff -c -p -d -r1.12 doloop.c
*** doloop.c	2001/11/16 02:26:38	1.12
--- doloop.c	2001/11/27 22:06:50
*************** doloop_modify_runtime (loop, iterations_
*** 596,601 ****
--- 596,641 ----
  			      copy_rtx (neg_inc ? final_value : initial_value),
  			      NULL_RTX, unsigned_p, OPTAB_LIB_WIDEN);
  
+   /* Some code transformations can result in code akin to
+ 
+ 	  tmp = i + 1;
+ 	  ...
+ 	  goto scan_start;
+ 	top:
+ 	  tmp = tmp + 1;
+ 	scan_start:
+ 	  i = tmp;
+ 	  if (i < n) goto top;
+ 
+      We'll have already detected this form of loop in scan_loop,
+      and set loop->top and loop->scan_start appropriately.
+ 
+      In this situation, we skip the increment the first time through
+      the loop, which results in an incorrect estimate of the number
+      of iterations.  Adjust the difference to compensate.  */
+   /* ??? Logically, it would seem this belongs in loop_iterations.
+      However, this causes regressions e.g. on x86 execute/20011008-3.c,
+      so I do not believe we've properly characterized the exact nature
+      of the problem.  In the meantime, this fixes execute/20011126-2.c
+      on ia64 and some Ada front end miscompilation on ppc.  */
+ 
+   if (loop->scan_start)
+     {
+       struct loop_ivs *ivs = LOOP_IVS (loop);
+       struct iv_class *bl
+ 	= REG_IV_CLASS (ivs, REGNO (loop_info->iteration_var));
+ 
+       if (INSN_LUID (bl->biv->insn) < INSN_LUID (loop->scan_start))
+ 	{
+ 	  if (loop_dump_stream)
+ 	    fprintf (loop_dump_stream,
+ 	         "Doloop: Basic induction var skips initial incr.\n");
+ 
+ 	  diff = expand_simple_binop (mode, PLUS, diff, increment, diff,
+ 				      unsigned_p, OPTAB_LIB_WIDEN);
+ 	}
+     }
+ 
    if (abs_inc * loop_info->unroll_number != 1)
      {
        int shift_count;


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