more on fortran array indexing

Toon Moene toon@moene.indiv.nluug.nl
Fri Oct 3 01:33:00 GMT 1997


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



More information about the Gcc mailing list