Mon, 17 Apr 1995 00:19:16 GMT

Related articles |
---|

[6 earlier articles] |

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) |

Re: Q: division vs multiplication davidm@flora.Rational.com (1995-04-28) |

Re: Q: division vs multiplication Roger@natron.demon.co.uk (Roger Barnett) (1995-04-28) |

Re: Q: division vs multiplication jmccarty@spdmail.spd.dsccc.com (1995-04-29) |

Newsgroups: | comp.compilers |

From: | kptben@aol.com (KPT Ben) |

Keywords: | arithmetic |

Organization: | America Online, Inc. (1-800-827-6364) |

References: | 95-04-080 |

Date: | Mon, 17 Apr 1995 00:19:16 GMT |

martens@cis.ohio-state.edu (Jeff Martens) wrote:

*>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

On the PPC, you can divide any signed 32-bit integer by 2^n by using (in

PPC assembly):

srawi dst, src, n //arithmetic-shift (generates carry bit if dst < 0)

addze dst, dst //add carry bit to dst

and it will give identical results to dividing by 2^n.

--

Ben Weiss

HSC Software

--

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.