From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toon Moene To: Richard Henderson Cc: egcs@cygnus.com Subject: Re: more on fortran array indexing Date: Fri, 03 Oct 1997 01:33:00 -0000 Message-id: <9710030816.AA26550@moene.indiv.nluug.nl> References: <19971002130319.01737@dot.cygnus.com> X-SW-Source: 1997-10/msg00149.html > Last night I examined the differences in the output of > the friendlier FASTER_ARRAY_REFS, and the patched expr.c > ARRAY_REF. > > They output, respectively, > > addr = ((n*64)/8 * (j-1)) + (i*8) + base - 8 > > and > > addr = (i-1)*8 + ((j-1) * (n*64)) / 8 + base > > IMO, it is obviously the FLOOR_DIV 8 that is causing the > problem. Please try the following patch: * fold-const (fold): Also simplify FLOOR_DIV_EXPR iff dividend is a multiple of divisor *** egcs-970929/gcc/fold-const.c.orig Fri Oct 3 10:07:37 1997 --- egcs-970929/gcc/fold-const.c Fri Oct 3 10:09:53 1997 *************** fold (expr) *** 4611,4619 **** operation, EXACT_DIV_EXPR. ! Note that only CEIL_DIV_EXPR is rewritten now, only because the ! others seem to be faster in some cases. This is probably just ! due to more work being done to optimize others in expmed.c than on ! EXACT_DIV_EXPR. */ ! if (code == CEIL_DIV_EXPR && multiple_of_p (type, arg0, arg1)) return fold (build (EXACT_DIV_EXPR, type, arg0, arg1)); --- 4611,4619 ---- operation, EXACT_DIV_EXPR. ! Note that only CEIL_DIV_EXPR and FLOOR_DIV_EXPR are rewritten now, ! only because the others seem to be faster in some cases. ! This is probably just due to more work being done to optimize ! others in expmed.c than on EXACT_DIV_EXPR. */ ! if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR) && multiple_of_p (type, arg0, arg1)) return fold (build (EXACT_DIV_EXPR, type, arg0, arg1)); Cheers, Toon.