Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!gatech!amdcad!tim From: tim@amdcad.UUCP Newsgroups: comp.arch Subject: Re: Optimization vs. the programmer Message-ID: <16090@amdcad.AMD.COM> Date: Sun, 12-Apr-87 14:48:06 EST Article-I.D.: amdcad.16090 Posted: Sun Apr 12 14:48:06 1987 Date-Received: Mon, 13-Apr-87 06:20:12 EST References: <479@danews.ATT.COM> <3300003@uiucdcsm> <3135@jade.BERKELEY.EDU> Organization: Advanced Micro Devices, Inc., Sunnyvale, Ca. Lines: 33 Summary: few (if any) current machines work this way... In article <3135@jade.BERKELEY.EDU>, desj@lemon.BERKELEY.EDU (David desJardins) writes: > 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. I think you should be more explicit in what you are stating here. The strength-reduction optimization above does *not* work for signed dividends (j, in this case) on most current machines, since they define the remainder to have the same sign as the dividend. Thus, you seem to be arguing that this definition be changed to one where remainders are always positive and integer divide operations always round *down* instead of towards zero (this is required for (a/b)*b + a%b == a I seem to remember reading that the PL.8 compiler for the IBM ROMP chip used this definition for divide operations so that the compiler could perform this very optimization. There was a discussion a while (1 yr?) ago about this subject, but I can't remember what conclusions were made (if any). Anyone care to refresh our memories? Tim Olson Advanced Micro Devices (tim@amdcad.AMD.COM)