Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!claris!apple!bcase From: bcase@Apple.COM (Brian Case) Newsgroups: comp.arch Subject: Re: RISC is a nasty no-no! Message-ID: <7522@apple.Apple.Com> Date: 1 Mar 88 19:40:42 GMT References: <179@wsccs.UUCP: <696@nuchat.UUCP> <284@scdpyr.UUCP> <11199@duke.cs.duke.edu> <7649@pur-ee.UUCP> Reply-To: bcase@apple.UUCP (Brian Case) Organization: Ungermann-Bass Enterprises Lines: 19 In article <7649@pur-ee.UUCP> hankd@pur-ee.UUCP (Hank Dietz) writes: >The multiply for indexing is, first of all, often converted into >bumping pointers if you have a good optimizing compiler and, >secondly, unless you have a VERY FAST multiply, multiplying by >VIRTUALLY ANY compile-time CONSTANT (e.g., sizeof an element) >is faster using shift and add/subtract instructions. For example, a >multiply by 7 (not a nice power of 2) is really shift to multiply >by 8 and then subtract the original number. This sort of thing is >widely known by compiler writers -- references are available -- >and the big disadvantage to it is that it may require the use of >more registers for temporaries. Yes, you might need more registers. Plus, now that you have computed the multiply by 8, it is possible to reuse this computation later if it is needed. This is one of the easiest ways to see that lots of registers, three-address operations, and a smart compiler are good. I've said it before and I'll say it again: RISC is both "hardware with a very short cycle time" and a philosophy: "reuse rather than recompute." Note that a RISC machine, a memory reference can be a significant computation.