Article View: comp.sys.amiga.tech
Article #10383Re: Aztec compiler ineffeciencies
From: Peter da Silva
Date: Sat, 26 Nov 1988 22:31
Date: Sat, 26 Nov 1988 22:31
34 lines
2033 bytes
2033 bytes
In article <7949@dasys1.UUCP>, rodd@dasys1.UUCP (Rod Dorman) writes:
> In article <3013@sugar.uu.net> karl@sugar.uu.net (Karl Lehenbauer) writes:
> >I've been examining the output of Aztec 3.6a and have discovered that it does
> >no optimization on divides, such as turning divides by constants into shifts
> > asr.l #1,d4
> As many compiler writers have found in the past and I'm sure many will
> rediscover in the future, this only works for positive values. Try
> shifting -1 and you'll get -1 as a result, *not* zero as one would expect.
First consider (unsigned)/2. Then...
As many compiler users in the past have discovered, having -1/2 == -1 is
often much more useful... particularly with graphics applications. This
depends on how you interpret integer arithmetic... should division be
truncated towards zero (trunc), to the numerically lower value (floor),
or the numerically higher value (cieling). Mathemeticians like trunc, but
this leads to a singularity at 0. Say that, for some reason, you're drawing
a line at arctan(1/2) using a straightforward algorithm, and it goes through
the origin.
With trunc With floor
** **
** **
*** **
** **
** **
See comp.lang.c for assorted flames.
--
Peter da Silva `-_-' peter@sugar.uu.net
Have you hugged U your wolf today?
Disclaimer: My typos are my own damn busines#!rne
Technical Details
Message-ID:
<3024@sugar.uu.net>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!bellcore!texbell!sugar!peterReferences:
<3013@sugar.uu.net> <7949@dasys1.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!bellcore!texbell!sugar!peter From: peter@sugar.uu.net (Peter da Silva) Newsgroups: comp.sys.amiga.tech Subject: Re: Aztec compiler ineffeciencies Message-ID: <3024@sugar.uu.net> Date: 26 Nov 88 22:31:50 GMT References: <3013@sugar.uu.net> <7949@dasys1.UUCP> Organization: Sugar Land Unix - Houston, TX Lines: 34