loop.c (loop_unroll_factor): Move outside #ifdef HAIFA conditional.
authorJeff Law <law@gcc.gnu.org>
Mon, 22 Sep 1997 01:49:19 +0000 (19:49 -0600)
committerJeff Law <law@gcc.gnu.org>
Mon, 22 Sep 1997 01:49:19 +0000 (19:49 -0600)
        * loop.c (loop_unroll_factor): Move outside #ifdef HAIFA
        conditional.
        (loop_unroll_iter): Remove unused variable and all references.
        (loop_optimize): Always allocate and clear space for loop_unroll_factor.
        (insert_bct): Fix minor formatting problems.
        * loop.h (loop_unroll_factor): Move decl outside #ifdef HAIFA.
        (loop_unroll_iter): Removed unused decl.
        * unroll.c (unroll_loop): Remove code to set loop_unroll_iter.
        Always record the unrolling factor.
More haifa cleanup

From-SVN: r15621

gcc/loop.c
gcc/loop.h
gcc/unroll.c

index 3bbe74198efba35ef7bcc025deedb6b8c267b17d..a72fdcbc427a7f83068ad984a544ccf93f136304 100644 (file)
@@ -91,15 +91,6 @@ int *loop_can_insert_bct;
 
 int *loop_used_count_register;
 
-/* For each loop, remember its unrolling factor (if at all).
-   contents of the array:
-   0/1: not unrolled.
-   -1: completely unrolled - no further instrumentation is needed.
-   >1: holds the exact amount of unrolling.  */
-
-int *loop_unroll_factor;
-int *loop_unroll_iter;
-
 /* loop parameters for arithmetic loops. These loops have a loop variable
    which is initialized to loop_start_value, incremented in each iteration
    by "loop_increment".  At the end of the iteration the loop variable is
@@ -111,6 +102,13 @@ rtx *loop_start_value;
 enum rtx_code *loop_comparison_code;
 #endif  /* HAIFA */
 
+/* For each loop, keep track of its unrolling factor.
+   Potential values:
+      0: unrolled
+      1: not unrolled.
+     -1: completely unrolled
+     >0: holds the unroll exact factor.  */
+int *loop_unroll_factor;
 
 /* Indexed by loop number, contains a nonzero value if the "loop" isn't
    really a loop (an insn outside the loop branches into it).  */
@@ -431,6 +429,12 @@ loop_optimize (f, dumpfile)
   loop_number_exit_labels = (rtx *) alloca (max_loop_num * sizeof (rtx));
   loop_number_exit_count = (int *) alloca (max_loop_num * sizeof (int));
 
+  /* This is initialized by the unrolling code, so we go ahead
+     and clear them just in case we are not performing loop
+     unrolling.  */
+  loop_unroll_factor = (int *) alloca (max_loop_num *sizeof (int));
+  bzero ((char *) loop_unroll_factor, max_loop_num * sizeof (int));
+
 #ifdef HAIFA
   /* Allocate for BCT optimization */
   loop_can_insert_bct = (int *) alloca (max_loop_num * sizeof (int));
@@ -439,12 +443,6 @@ loop_optimize (f, dumpfile)
   loop_used_count_register = (int *) alloca (max_loop_num * sizeof (int));
   bzero ((char *) loop_used_count_register, max_loop_num * sizeof (int));
 
-  loop_unroll_factor = (int *) alloca (max_loop_num *sizeof (int));
-  bzero ((char *) loop_unroll_factor, max_loop_num * sizeof (int));
-
-  loop_unroll_iter = (int *) alloca (max_loop_num *sizeof (int));
-  bzero ((char *) loop_unroll_iter, max_loop_num * sizeof (int));
-
   loop_increment = (rtx *) alloca (max_loop_num * sizeof (rtx));
   loop_comparison_value = (rtx *) alloca (max_loop_num * sizeof (rtx));
   loop_start_value = (rtx *) alloca (max_loop_num * sizeof (rtx));
@@ -7277,12 +7275,9 @@ insert_bct (loop_start, loop_end)
     return;
   }
 
-  /* make sure that the loop was not fully unrolled.  */
-  if (loop_unroll_factor[loop_num] == -1){
-    if (loop_dump_stream)
-      fprintf (loop_dump_stream, "insert_bct %d: was completely unrolled\n", loop_num);
+  /* It's impossible to instrument a competely unrolled loop.  */
+  if (loop_unroll_factor [loop_num] == -1)
     return;
-  }
 
   /* make sure that the last loop insn is a conditional jump .
      This check is repeated from analyze_loop_iterations (),
@@ -7296,8 +7291,8 @@ insert_bct (loop_start, loop_end)
   }
 
   /* fix increment in case loop was unrolled.  */
-  if (loop_unroll_factor[loop_num] > 1)
-    increment = GEN_INT ( INTVAL (increment) * loop_unroll_factor[loop_num] );
+  if (loop_unroll_factor [loop_num] > 1)
+    increment = GEN_INT ( INTVAL (increment) * loop_unroll_factor [loop_num] );
 
   /* determine properties and directions of the loop */
   increment_direction = (INTVAL (increment) > 0) ? 1:-1;
index d8c83cdcab6a5f0a9993c0d96a068af861f75c96..44e150020282a757e5f7219af79434e28e2cd0ef 100644 (file)
@@ -182,12 +182,11 @@ rtx final_giv_value PROTO((struct induction *, rtx, rtx));
 void emit_unrolled_add PROTO((rtx, rtx, rtx));
 int back_branch_in_range_p PROTO((rtx, rtx, rtx));
 
+extern int *loop_unroll_factor;
 #ifdef HAIFA
 /* variables for interaction between unroll.c and loop.c, for
    the insertion of branch-on-count instruction. */
-extern int *loop_unroll_factor;
 extern rtx *loop_start_value;
-extern int *loop_unroll_iter;
 extern int loop_number();
 #endif  /* HAIFA */
 
index ce6623c37cd750cd784311b0251e0c3d3ec76242..b9cbcfe6a48b144ffc7b67ac54b9056c238b6f26 100644 (file)
@@ -1094,16 +1094,13 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
          /* Set unroll type to MODULO now.  */
          unroll_type = UNROLL_MODULO;
          loop_preconditioned = 1;
+
 #ifdef HAIFA
-         if (loop_n_iterations > 0)
-           loop_unroll_iter[ loop_number(loop_start, loop_end) ]
-             = (loop_n_iterations
-                 - loop_n_iterations % (abs_inc * unroll_number));
-         else
-           /* inform loop.c about the new initial value */
-           loop_start_value[loop_number(loop_start, loop_end)] = initial_value;
+         /* Fix the initial value for the loop as needed.  */
+         if (loop_n_iterations <= 0)
+           loop_start_value [loop_number (loop_start, loop_end)]
+             = initial_value;
 #endif
-
        }
     }
 
@@ -1118,13 +1115,11 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
 
   /* At this point, we are guaranteed to unroll the loop.  */
 
-#ifdef HAIFA
-  /* inform loop.c about the factor of unrolling */
+  /* Keep track of the unroll factor for each loop.  */
   if (unroll_type == UNROLL_COMPLETELY)
-    loop_unroll_factor[ loop_number(loop_start, loop_end) ] = -1;
+    loop_unroll_factor [loop_number (loop_start, loop_end)] = -1;
   else
-    loop_unroll_factor[ loop_number(loop_start, loop_end) ] = unroll_number;
-#endif  /* HAIFA */
+    loop_unroll_factor [loop_number (loop_start, loop_end)] = unroll_number;
 
 
   /* For each biv and giv, determine whether it can be safely split into