Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!umd5!uvaarpa!mcnc!ecsvax!tpmsph From: tpmsph@ecsvax.UUCP (Thomas P. Morris) Newsgroups: comp.arch Subject: Re: RISC is a nasty no-no! Message-ID: <4699@ecsvax.UUCP> Date: 1 Mar 88 12:21:21 GMT References: <179@wsccs.UUCP: <696@nuchat.UUCP> <284@scdpyr.UUCP> <11199@duke.cs.duke.edu> Organization: UNC Educational Computing Service Lines: 30 Summary: good programmers vs good compilers In response to a posting about RISC having "bad" performance due to array indexing which might require heavy integer multiplication, David Kotz points out: > Multiplication is not necessary to access 2-D arrays if the array is > set up like most arrays in C, where each row is a typical vector and > the 2-D array is just a vector of pointers to each row vector. Then > double-indirection is necessary, rather than multiplication. I won't > say that's any better, but you don't *need* multiplication. (It might > not be so bad once the first two pointers are cached, and a good > programmer puts them in registers anyway). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Two points: (1) a good programmer shouldn't have to put those pointers into registers. That's what good compilers are for! ;-) (2) If your array elements are being accessed sequentially, a good _optimizing_ compiler ought to be changing those array-index computations with addititively computed offsets from a base. Strength reduction, code hoisting, and elimination or reduction of invariant computations can do wonders for code! Of course, a good programmer _would_ indicate to his/her "C" compiler that the indices or the pointers ought to go in registers, too! ----------------------------------------------------------------------------- Tom Morris BITNET: TOM@UNCSPHVX UNC School of Public Health UUCP : ...!mcnc!ecsvax!tpmsph "It's a joke, boy! I say, it's a joke! Don't ya get it?" -Foghorn Leghorn -----------------------------------------------------------------------------