Re: Q: division vs multiplication

martens@cis.ohio-state.edu (Jeff Martens)
Sun, 16 Apr 1995 19:13:50 GMT

          From comp.compilers

Related articles
[3 earlier articles]
Re: Q: division vs multiplication mikeq@primenet.com (1995-04-02)
Re: Q: division vs multiplication hbaker@netcom.com (1995-04-03)
Re: Q: division vs multiplication davidm@Rational.COM (1995-04-03)
Re: Q: division vs multiplication brandis@inf.ethz.ch (1995-04-04)
Re: Q: division vs multiplication Terje.Mathisen@hda.hydro.com (1995-04-06)
Re: Q: division vs multiplication meissner@cygnus.com (Mike Meissner) (1995-04-16)
Re: Q: division vs multiplication martens@cis.ohio-state.edu (1995-04-16)
Re: Q: division vs multiplication jmccarty@spdmail.spd.dsccc.com (1995-04-18)
Re: Q: division vs multiplication leichter@zodiac.rutgers.edu (1995-04-11)
Re: Q: division vs multiplication kptben@aol.com (1995-04-17)
Re: Q: division vs multiplication pcg@aber.ac.uk (1995-04-17)
Re: Q: division vs multiplication gsc@magna.com.au (1995-04-18)
Re: Q: division vs multiplication jbuck@Synopsys.COM (1995-04-28)
[4 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: martens@cis.ohio-state.edu (Jeff Martens)
Keywords: arithmetic, optimize
Organization: Hood College Dept. of Math and CS
References: 95-04-003 95-04-039
Date: Sun, 16 Apr 1995 19:13:50 GMT

>t.hulek@imperial.ac.uk (Mr Tomas Hulek) wrote:
>[Can one optimize floating division by powers of two into something like a
>shift?]


kptben@aol.com (KPT Ben) writes:
>When using 32-bit integer math on the PowerPC 601, a brute-force divide is
>36 cycles; a multiply is 5 cycles, and bitshifts are 1 cycle.
>Multiplication and division by powers of two can be done with a single
>bitshift instruction on the 601 (two instructions are necessary when
>dividing a signed integer by a power of 2).


You have to be careful here, though, because a right arithmetic
shift of an odd negative integer will not give the same result as
division by 2. For example:


-1 div 2 is 0
ashr(-1) is -1
--


-- Jeff (jmartens@nimue.hood.edu)
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.