Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site mips.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!drutx!mtuxo!mtunh!mtung!mtunf!ariel!vax135!timeinc!phri!pesnta!amd!amdcad!decwrl!Glacier!mips!mash
From: mash@mips.UUCP (John Mashey)
Newsgroups: net.micro.68k,net.arch
Subject: Re: RISC (really on multiplication due to structures)
Message-ID: <149@mips.UUCP>
Date: Sun, 30-Jun-85 14:26:16 EDT
Article-I.D.: mips.149
Posted: Sun Jun 30 14:26:16 1985
Date-Received: Wed, 3-Jul-85 08:21:14 EDT
References: <639@vax2.fluke.UUCP> <2743@nsc.UUCP> <576@terak.UUCP> <5690@utzoo.UUCP> <1109@peora.UUCP> <5716@utzoo.UUCP> <78@rtp47.UUCP>
Distribution: net
Organization: MIPS Computer Systems, Mountain View, CA
Lines: 31
Xref: watmath net.micro.68k:980 net.arch:1518

Michael Meissner ...{ ihnp4, decvax }!mcnc!rti-sel!rtp47!meissner writes:
> Another case where multiplication occurs frequently is contructs of the
> sort:
> 	struct {
> 		long	l;
> 		short	s;
> 	} *p;
> 	int	i;
> 	main(){
> 		/*...*/
> 		p += i;
> 		p[i].l = 1;
> 		/*...*/
> 	}
> Ie, pointer arithmetic involving non-constant integers, particularly if
> the size is not a multiple of 2.

1) In this example, sizeof(*p) == 8 anyway.  To get the intended effect,
use short l[2], for example.
2) In any case, at least some compilers not only do multiplies of
powers of 2 by adds or shifts, but do so for constants that are almost
powers of 2 (i.e., few 1-bits) by shifts and adds or subtracts.
3) Indeed, multiplication does occur frequently in these cases; the real
question, is how frequent are these cases, really? [Not an answer, but
a question whose answer needs to be known when you're making tradeoffs
in CPU design].
-- 
-john mashey
UUCP: 	{decvax,ucbvax,ihnp4}!decwrl!mips!mash
DDD:  	415-960-1200
USPS: 	MIPS Computer Systems, 1330 Charleston Rd, Mtn View, CA 94043