Stabilization on the ARM: an unrolling bug

Michael Hayes m.hayes@elec.canterbury.ac.nz
Fri Jan 8 02:38:00 GMT 1999


Michael Hayes writes:
 > This loop raises some interesting issues.  
 > 
 > 1. It has two back edges which has confused the loop iteration
 > calculating code since it only found the second back edge. 

Richard, can you try this patch to see if it solves your problem.
It looks to see if there is more than one use of the label at the top
of the loop and punts calculating the loop iteration info if this is
the case.

Michael.

Fri Jan  8 23:29:26 1999  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>

	* unroll.c (loop_iterations): Return 0 if the loop has multiple
	back edges.

Index: unroll.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/unroll.c,v
retrieving revision 1.41
diff -c -3 -p -r1.41 unroll.c
*** unroll.c	1999/01/06 19:45:50	1.41
--- unroll.c	1999/01/08 10:29:58
*************** loop_iterations (loop_start, loop_end, l
*** 3477,3492 ****
    loop_info->unroll_number = 1;
    loop_info->vtop = 0;
  
-   /* First find the iteration variable.  If the last insn is a conditional
-      branch, and the insn before tests a register value, make that the
-      iteration variable.  */
-   
    /* We used to use prev_nonnote_insn here, but that fails because it might
       accidentally get the branch for a contained loop if the branch for this
       loop was deleted.  We can only trust branches immediately before the
       loop_end.  */
    last_loop_insn = PREV_INSN (loop_end);
  
    comparison = get_condition_for_loop (last_loop_insn);
    if (comparison == 0)
      {
--- 3477,3504 ----
    loop_info->unroll_number = 1;
    loop_info->vtop = 0;
  
    /* We used to use prev_nonnote_insn here, but that fails because it might
       accidentally get the branch for a contained loop if the branch for this
       loop was deleted.  We can only trust branches immediately before the
       loop_end.  */
    last_loop_insn = PREV_INSN (loop_end);
  
+   /* If there is a more than a single jump to the top of the loop
+      we cannot (easily) determine the iteration count.  */
+   if (GET_CODE (last_loop_insn) != JUMP_INSN)
+     abort();
+   if (LABEL_NUSES (JUMP_LABEL (last_loop_insn)) > 1)
+     {
+       if (loop_dump_stream)
+ 	fprintf (loop_dump_stream,
+ 		 "Loop iterations: Loop has multiple back edges.\n");
+       return 0;
+     }
+ 
+   /* Find the iteration variable.  If the last insn is a conditional
+      branch, and the insn before tests a register value, make that the
+      iteration variable.  */
+   
    comparison = get_condition_for_loop (last_loop_insn);
    if (comparison == 0)
      {




More information about the Gcc-patches mailing list