Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!hao!husc6!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.arch Subject: Re: RISC is a nasty no-no! Message-ID: <4399@aw.sei.cmu.edu> Date: 1 Mar 88 13:38:59 GMT References: <179@wsccs.UUCP: <696@nuchat.UUCP> <284@scdpyr.UUCP> <11199@duke.cs.duke.edu> <998@PT.CS.CMU.EDU> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 15 In article <998@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes: >EXCUSE ME, but when I declare an array to be an n by m matrix in >C (float foo[n][m]) I get a contiguous block of memory. The >representation IS NOT row-vector or column-vector. So when I access >index number i,j someone has to perform the calculation >base + sizeof(type)*(i*m+j). However, going by Knuth's statistics on array usage, more than 95% of those multiplications occur in loops where the index is the induction variable. The optimisation called "strength reduction" can then remove them. If your target machine has a slow multiply, such an optimisation is probably necessary. How to do it is explained in detail in many books, including eg Wulf's 'The Design of an Optimising Compiler'. The first Fortran compiler included this optimisation, so it's been around for quite a while.