Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ames!ucbcad!ucbvax!jade!brahms!desj From: desj@brahms.UUCP Newsgroups: comp.arch Subject: Re: Optimization vs. the programmer Message-ID: <3135@jade.BERKELEY.EDU> Date: Sat, 11-Apr-87 17:24:04 EST Article-I.D.: jade.3135 Posted: Sat Apr 11 17:24:04 1987 Date-Received: Sun, 12-Apr-87 19:49:25 EST References: <479@danews.ATT.COM> <3300003@uiucdcsm> Sender: usenet@jade.BERKELEY.EDU Reply-To: desj@brahms.Berkeley.EDU (David desJardins) Organization: UC Berkeley Math Dept [IN EXILE] Lines: 11 In article <3300003@uiucdcsm> grunwald@uiucdcsm.cs.uiuc.edu writes: > >Strength reduction is replacement of operations such as "i = j * 8" by >"i = j << 3", or "i = j % 8" by "i = j & 0x3" (if j is unsigned). ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ I'm sure you mean "i = j & 0x7". But, more importantly, this is the right remainder to compute even if j is signed (assuming two's-complement, of course). It's too bad more people (especially hardware designers!) don't realize this. -- David desJardins