diff options
author | Dale Johannesen <dalej@apple.com> | 2002-11-04 20:06:28 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@gcc.gnu.org> | 2002-11-04 20:06:28 +0000 |
commit | 2aff950822bee20e1398a2a528ad927740f799f8 (patch) | |
tree | 757f262de1fc974cf8a0f7aebb26aea20afbf563 /gcc/doloop.c | |
parent | e86e721fc7b44cdd46c72f60de48af228d7df4b9 (diff) | |
download | gcc-2aff950822bee20e1398a2a528ad927740f799f8.zip gcc-2aff950822bee20e1398a2a528ad927740f799f8.tar.gz gcc-2aff950822bee20e1398a2a528ad927740f799f8.tar.bz2 |
Fix bugs that showed up building Spec on ppc darwin.
From-SVN: r58800
Diffstat (limited to 'gcc/doloop.c')
-rw-r--r-- | gcc/doloop.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/gcc/doloop.c b/gcc/doloop.c index 1f7d47a..67b742c 100644 --- a/gcc/doloop.c +++ b/gcc/doloop.c @@ -599,16 +599,19 @@ 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 - However, in certain cases the unrolled loop will be preconditioned - by emitting copies of the loop body with conditional branches, - so that the unrolled loop is always a full loop and thus needs - no exit tests. In this case we don't want to add the partial - loop count. As above, when t1 is a power of two we don't need to - worry about overflow. + n = (abs (final - initial) + t1 - 1) / t1; + + In the case where the loop was preconditioned, a few iterations + may have been executed earlier; but 'initial' was adjusted as they + were executed, so we don't need anything special for that case here. + As above, when t1 is a power of two we don't need to worry about + overflow. The division and modulo operations can be avoided by requiring that the increment is a power of 2 (precondition_loop_p enforces @@ -683,10 +686,10 @@ doloop_modify_runtime (loop, iterations_max, if (shift_count < 0) abort (); - if (!loop_info->preconditioned) - 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) */ + 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) */ |