Commit 237a9795 by Jeff Law

loop.c (loop_unroll_factor): Move outside #ifdef HAIFA conditional.

        * 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
parent 813f674a
...@@ -91,15 +91,6 @@ int *loop_can_insert_bct; ...@@ -91,15 +91,6 @@ int *loop_can_insert_bct;
int *loop_used_count_register; 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 /* loop parameters for arithmetic loops. These loops have a loop variable
which is initialized to loop_start_value, incremented in each iteration which is initialized to loop_start_value, incremented in each iteration
by "loop_increment". At the end of the iteration the loop variable is by "loop_increment". At the end of the iteration the loop variable is
...@@ -111,6 +102,13 @@ rtx *loop_start_value; ...@@ -111,6 +102,13 @@ rtx *loop_start_value;
enum rtx_code *loop_comparison_code; enum rtx_code *loop_comparison_code;
#endif /* HAIFA */ #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 /* Indexed by loop number, contains a nonzero value if the "loop" isn't
really a loop (an insn outside the loop branches into it). */ really a loop (an insn outside the loop branches into it). */
...@@ -431,6 +429,12 @@ loop_optimize (f, dumpfile) ...@@ -431,6 +429,12 @@ loop_optimize (f, dumpfile)
loop_number_exit_labels = (rtx *) alloca (max_loop_num * sizeof (rtx)); loop_number_exit_labels = (rtx *) alloca (max_loop_num * sizeof (rtx));
loop_number_exit_count = (int *) alloca (max_loop_num * sizeof (int)); 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 #ifdef HAIFA
/* Allocate for BCT optimization */ /* Allocate for BCT optimization */
loop_can_insert_bct = (int *) alloca (max_loop_num * sizeof (int)); loop_can_insert_bct = (int *) alloca (max_loop_num * sizeof (int));
...@@ -439,12 +443,6 @@ loop_optimize (f, dumpfile) ...@@ -439,12 +443,6 @@ loop_optimize (f, dumpfile)
loop_used_count_register = (int *) alloca (max_loop_num * sizeof (int)); loop_used_count_register = (int *) alloca (max_loop_num * sizeof (int));
bzero ((char *) loop_used_count_register, 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_increment = (rtx *) alloca (max_loop_num * sizeof (rtx));
loop_comparison_value = (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)); loop_start_value = (rtx *) alloca (max_loop_num * sizeof (rtx));
...@@ -7277,12 +7275,9 @@ insert_bct (loop_start, loop_end) ...@@ -7277,12 +7275,9 @@ insert_bct (loop_start, loop_end)
return; return;
} }
/* make sure that the loop was not fully unrolled. */ /* It's impossible to instrument a competely unrolled loop. */
if (loop_unroll_factor[loop_num] == -1){ if (loop_unroll_factor [loop_num] == -1)
if (loop_dump_stream)
fprintf (loop_dump_stream, "insert_bct %d: was completely unrolled\n", loop_num);
return; return;
}
/* make sure that the last loop insn is a conditional jump . /* make sure that the last loop insn is a conditional jump .
This check is repeated from analyze_loop_iterations (), This check is repeated from analyze_loop_iterations (),
...@@ -7296,8 +7291,8 @@ insert_bct (loop_start, loop_end) ...@@ -7296,8 +7291,8 @@ insert_bct (loop_start, loop_end)
} }
/* fix increment in case loop was unrolled. */ /* fix increment in case loop was unrolled. */
if (loop_unroll_factor[loop_num] > 1) if (loop_unroll_factor [loop_num] > 1)
increment = GEN_INT ( INTVAL (increment) * loop_unroll_factor[loop_num] ); increment = GEN_INT ( INTVAL (increment) * loop_unroll_factor [loop_num] );
/* determine properties and directions of the loop */ /* determine properties and directions of the loop */
increment_direction = (INTVAL (increment) > 0) ? 1:-1; increment_direction = (INTVAL (increment) > 0) ? 1:-1;
......
...@@ -182,12 +182,11 @@ rtx final_giv_value PROTO((struct induction *, rtx, rtx)); ...@@ -182,12 +182,11 @@ rtx final_giv_value PROTO((struct induction *, rtx, rtx));
void emit_unrolled_add PROTO((rtx, rtx, rtx)); void emit_unrolled_add PROTO((rtx, rtx, rtx));
int back_branch_in_range_p PROTO((rtx, rtx, rtx)); int back_branch_in_range_p PROTO((rtx, rtx, rtx));
extern int *loop_unroll_factor;
#ifdef HAIFA #ifdef HAIFA
/* variables for interaction between unroll.c and loop.c, for /* variables for interaction between unroll.c and loop.c, for
the insertion of branch-on-count instruction. */ the insertion of branch-on-count instruction. */
extern int *loop_unroll_factor;
extern rtx *loop_start_value; extern rtx *loop_start_value;
extern int *loop_unroll_iter;
extern int loop_number(); extern int loop_number();
#endif /* HAIFA */ #endif /* HAIFA */
...@@ -1094,16 +1094,13 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before, ...@@ -1094,16 +1094,13 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
/* Set unroll type to MODULO now. */ /* Set unroll type to MODULO now. */
unroll_type = UNROLL_MODULO; unroll_type = UNROLL_MODULO;
loop_preconditioned = 1; loop_preconditioned = 1;
#ifdef HAIFA #ifdef HAIFA
if (loop_n_iterations > 0) /* Fix the initial value for the loop as needed. */
loop_unroll_iter[ loop_number(loop_start, loop_end) ] if (loop_n_iterations <= 0)
= (loop_n_iterations loop_start_value [loop_number (loop_start, loop_end)]
- loop_n_iterations % (abs_inc * unroll_number)); = initial_value;
else
/* inform loop.c about the new initial value */
loop_start_value[loop_number(loop_start, loop_end)] = initial_value;
#endif #endif
} }
} }
...@@ -1118,13 +1115,11 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before, ...@@ -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. */ /* At this point, we are guaranteed to unroll the loop. */
#ifdef HAIFA /* Keep track of the unroll factor for each loop. */
/* inform loop.c about the factor of unrolling */
if (unroll_type == UNROLL_COMPLETELY) 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 else
loop_unroll_factor[ loop_number(loop_start, loop_end) ] = unroll_number; loop_unroll_factor [loop_number (loop_start, loop_end)] = unroll_number;
#endif /* HAIFA */
/* For each biv and giv, determine whether it can be safely split into /* For each biv and giv, determine whether it can be safely split into
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment