This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: array reference optimization
- To: Jim Wilson <wilson at cygnus dot com>, Richard Henderson <rth at cygnus dot com>
- Subject: Re: array reference optimization
- From: Richard Henderson <rth at cygnus dot com>
- Date: Sun, 17 May 1998 18:21:32 -0700
- Cc: egcs at cygnus dot com
- References: <19980513172502.54262@dot.cygnus.com> <199805172119.OAA03966@rtl.cygnus.com>
- Reply-To: Richard Henderson <rth at cygnus dot com>
On Sun, May 17, 1998 at 02:19:00PM -0700, Jim Wilson wrote:
> which requires doing the multiply in bitsizetype, we could do the divide
> first and then the multiple, something like this:
> oset = ... fold (build (MULT_EXPR, ssizetype, index,
> size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (...)
> size_int (BITS_PER_UNIT))))
> which keeps everything in range of sizetype.
It keeps it in the range of sizetype, yes, but my patch had a
secondary goal: that of eliminating a divide at runtime.
When the size of a type is not constant, as for the variables `res'
`rhs' and `u' in this simplified version of a function from spec95:
subroutine resid(res,u,rhs,n,h2i)
implicit none
integer n
double precision res(n,n),rhs(n,n),u(n,n)
integer i,j
double precision h2i
do j = 2, n-1
do i = 2, n-1
res(i,j)=-h2i*(u(i+1,j)+u(i-1,j)+u(i,j+1)+u(i,j-1)-
& 4.d0*u(i,j))+rhs(i,j)
enddo
enddo
end
We get, in part,
.prologue 1
bis $20,$20,$9
ldl $1,0($19) ; Load N
sll $1,6,$20 ; Multiply by 64
[...]
$L9:
subq $23,1,$8
s8addq $8,0,$8
bis $20,$20,$6
bis $31,$31,$7
srl $6,3,$6 ; Divide by 8
In my mind there is no excuse for this -- we should have only done
the multiply by 8 in the first place.
r~