From c8b64bf26dc94f4ab593dc3fb24aac2d9d23bf0e Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 30 Jun 2002 05:06:01 +0000 Subject: [PATCH] * unroll.c (loop_iterations): Handle EQ loops. From-SVN: r55111 --- gcc/ChangeLog | 4 ++++ gcc/unroll.c | 43 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 60cd8b809b7d..0ec03d0327be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2002-06-30 Alan Modra + + * unroll.c (loop_iterations): Handle EQ loops. + 2002-06-29 David Edelsohn * config/rs6000/rs6000.md (ctrdi): Allocate pseudo for FPR diff --git a/gcc/unroll.c b/gcc/unroll.c index a795dcbc202c..e0b0d36579d1 100644 --- a/gcc/unroll.c +++ b/gcc/unroll.c @@ -3941,12 +3941,6 @@ loop_iterations (loop) } return 0; } - else if (comparison_code == EQ) - { - if (loop_dump_stream) - fprintf (loop_dump_stream, "Loop iterations: EQ comparison loop.\n"); - return 0; - } else if (GET_CODE (final_value) != CONST_INT) { if (loop_dump_stream) @@ -3958,6 +3952,43 @@ loop_iterations (loop) } return 0; } + else if (comparison_code == EQ) + { + rtx inc_once; + + if (loop_dump_stream) + fprintf (loop_dump_stream, "Loop iterations: EQ comparison loop.\n"); + + inc_once = gen_int_mode (INTVAL (initial_value) + INTVAL (increment), + GET_MODE (iteration_var)); + + if (inc_once == final_value) + { + /* The iterator value once through the loop is equal to the + comparision value. Either we have an infinite loop, or + we'll loop twice. */ + if (increment == const0_rtx) + return 0; + loop_info->n_iterations = 2; + } + else + loop_info->n_iterations = 1; + + if (GET_CODE (loop_info->initial_value) == CONST_INT) + loop_info->final_value + = gen_int_mode ((INTVAL (loop_info->initial_value) + + loop_info->n_iterations * INTVAL (increment)), + GET_MODE (iteration_var)); + else + loop_info->final_value + = plus_constant (loop_info->initial_value, + loop_info->n_iterations * INTVAL (increment)); + loop_info->final_equiv_value + = gen_int_mode ((INTVAL (initial_value) + + loop_info->n_iterations * INTVAL (increment)), + GET_MODE (iteration_var)); + return loop_info->n_iterations; + } /* Final_larger is 1 if final larger, 0 if they are equal, otherwise -1. */ if (unsigned_p) -- 2.43.5