🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #13606

Re: Optimization vs. the programmer

#13606
From: tim
Date: Sun, 12 Apr 1987 19:48
33 lines
2133 bytes
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)
Technical Details
Message-ID: <16090@amdcad.AMD.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!cbatt!gatech!amdcad!tim
References: <479@danews.ATT.COM> <3300003@uiucdcsm> <3135@jade.BERKELEY.EDU>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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...