summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/doloop.c
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2003-02-10 05:41:50 +0000
committerkan <kan@FreeBSD.org>2003-02-10 05:41:50 +0000
commit793833d7a78bb624965885760593495e7079d705 (patch)
treef843ff90d71b900271088361ed96ff82eb2a365d /contrib/gcc/doloop.c
parent1b04fed26051ebc88f26a7bb93c63c270970e773 (diff)
downloadFreeBSD-src-793833d7a78bb624965885760593495e7079d705.zip
FreeBSD-src-793833d7a78bb624965885760593495e7079d705.tar.gz
Gcc 3.2.2-release.
Diffstat (limited to 'contrib/gcc/doloop.c')
-rw-r--r--contrib/gcc/doloop.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/gcc/doloop.c b/contrib/gcc/doloop.c
index 06d8d57..25deb503 100644
--- a/contrib/gcc/doloop.c
+++ b/contrib/gcc/doloop.c
@@ -598,9 +598,13 @@ doloop_modify_runtime (loop, iterations_max,
If the loop has been unrolled, the full calculation is
- t1 = abs_inc * unroll_number; increment per loop
- n = abs (final - initial) / t1; full loops
- n += (abs (final - initial) % t1) != 0; partial loop
+ t1 = abs_inc * unroll_number; increment per loop
+ n = (abs (final - initial) + abs_inc - 1) / t1; full loops
+ n += ((abs (final - initial) + abs_inc - 1) % t1) >= abs_inc;
+ partial loop
+ which works out to be equivalent to
+
+ n = (abs (final - initial) + t1 - 1) / t1;
However, in certain cases the unrolled loop will be preconditioned
by emitting copies of the loop body with conditional branches,
@@ -682,13 +686,15 @@ doloop_modify_runtime (loop, iterations_max,
if (shift_count < 0)
abort ();
- if (!loop_info->preconditioned)
+ if (loop_info->preconditioned)
+ diff = expand_simple_binop (GET_MODE (diff), PLUS,
+ diff, GEN_INT (abs_inc - 1),
+ diff, 1, OPTAB_LIB_WIDEN);
+ else
diff = expand_simple_binop (GET_MODE (diff), PLUS,
diff, GEN_INT (abs_loop_inc - 1),
diff, 1, OPTAB_LIB_WIDEN);
- /* (abs (final - initial) + abs_inc * unroll_number - 1)
- / (abs_inc * unroll_number) */
diff = expand_simple_binop (GET_MODE (diff), LSHIFTRT,
diff, GEN_INT (shift_count),
diff, 1, OPTAB_LIB_WIDEN);
OpenPOWER on IntegriCloud