Division by invariant integers using multiplication

  • Authors:
  • Torbjörn Granlund;Peter L. Montgomery

  • Affiliations:
  • -;-

  • Venue:
  • PLDI '94 Proceedings of the ACM SIGPLAN 1994 conference on Programming language design and implementation
  • Year:
  • 1994

Quantified Score

Hi-index 0.00

Visualization

Abstract

Integer division remains expensive on today's processors as thecost of integer multiplication declines. We present code sequences fordivision by arbitrary nonzero integer constants and run-time invariantsusing integer multiplication. The algorithms assume a two's complementarchitecture. Most also require that the upper half of an integerproduct be quickly accessible. We treat unsigned division, signeddivision where the quotient rounds towards zero, signed division wherethe quotient rounds towards -∞, and division where the result is knowna priori to be exact. We give someimplementation results using the C compiler GCC.