This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: fix SPEC regressions (rewrite)


On Thursday, October 31, 2002, at 05:41  PM, Richard Henderson wrote:

On Thu, Oct 31, 2002 at 03:22:19PM -0800, Dale Johannesen wrote:
I'll rewrite it simplified if you prefer.
Thanks.
Here you go. Bootstrapped and tested on Darwin; spec and PR 7130 work.

Index: doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.25
diff -u -d -b -w -c -3 -p -r1.25 doloop.c
*** doloop.c 7 Oct 2002 17:55:46 -0000 1.25
--- doloop.c 1 Nov 2002 20:32:40 -0000
*************** doloop_modify_runtime (loop, iterations_
*** 600,614 ****
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

! 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.

The division and modulo operations can be avoided by requiring
that the increment is a power of 2 (precondition_loop_p enforces
--- 600,617 ----
If the loop has been unrolled, the full calculation is

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;
!
! 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
*************** doloop_modify_runtime (loop, iterations_
*** 683,689 ****
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);
--- 686,692 ----
if (shift_count < 0)
abort ();

! /* (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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]