skip to main content
article
Free Access

Division by invariant integers using multiplication

Published:01 June 1994Publication History
Skip Abstract Section

Abstract

Integer division remains expensive on today's processors as the cost of integer multiplication declines. We present code sequences for division by arbitrary nonzero integer constants and run-time invariants using integer multiplication. The algorithms assume a two's complement architecture. Most also require that the upper half of an integer product be quickly accessible. We treat unsigned division, signed division where the quotient rounds towards zero, signed division where the quotient rounds towards -∞, and division where the result is known a priori to be exact. We give some implementation results using the C compiler GCC.

References

  1. 1 Robert Alverson. Integer division using reciprocals. In Peter Korncrup and David W. Matula, editors, Proceedzngs l Oth Symposium on Computer Arithmetzc, pages 186-190, Grenoble, France, June 1991.Google ScholarGoogle Scholar
  2. 2 Ehud Artzy, James A. Hinds, and Harry J. Saal. A fast division technique for constant divisors. CACM, 19(2):98-101, February 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3 Henry G. Baker. Computing A*B (mod N) efficiently in ANSI C. A CM ${GPLAN Notices, 27( 1):95-98, January 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 4 H.B. Bakoglu, G.F. Grohoski, and R. K. Montoye. The IBM RISC system/6000 processor: Hardware overview. IBM Journal of Research and Development, 34(1):12-22, January 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 5 Robert Bernstein. Multiplication by integer constants. Software- Practice and Experience, 16(7):641-652, July 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6 Raymond T. Boute. The Euclidean definition of the functions div and rood. ACM Transactions on Programming Languages and Systems, 14(2):127- 144, April 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 7 A.P. Chang. A note on the modulo operation. $IGPLAN Notices, 20(4):19-23, April 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8 Digital Equipment Corporation. DECchip 2106~~ AA Microprocessor, Hardware Reference Manual, 1st edition, October 1992.Google ScholarGoogle Scholar
  9. 9 Intel Corporation, Santa Clara, CA. 386 DX Microprocessor Programmer's Reference Manual, 1990.Google ScholarGoogle Scholar
  10. 10 intel Corporation, Santa Clara, CA. intelJ86 Microprocessor Family Programmer's Reference Manual, 1992.Google ScholarGoogle Scholar
  11. 11 David H. Jacobsohn. A combinatoric division algorithm for fixed-integer divisors. IEEE Trans. Comp., C-22(6):608-610, June 1973.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 12 Gerry Kane. MIP$ RI$C Architecture. Prentice Hall, Englewood Cliffs, NJ, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 13 Donald E. Knuth. An empirical study of FOR- TRAN programs. Technical Report CS-186, Computer Science Department, Stanford University, 1970. Stanford artificial intelligence project memo AIM-137.Google ScholarGoogle Scholar
  14. 14 Donald E. Knuth. Semznumerical Algorzthms, volume 2 of The Art of Computer Programming. Addison-Wesley, Reading, MA, 2nd edition, 1981.Google ScholarGoogle Scholar
  15. 15 Shuo-Yen Robert Li. Fast constant division routines. IEEE Trans. Comp., C-34(9):866-869, September 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 16 Daniel J. Magenheimer, Liz Peters, Karl Pettis, and Dan Zuras. Integer multiplication and division on the HP Precision Architecture. In Proceedings Second International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS II). ACM, 1987. Published as SIGPLAN Notices, Volume 22, No. 10, October, 1987. Google ScholarGoogle ScholarCross RefCross Ref
  17. 17 MIPS Computer Systems, Inc, Sunnyvale, CA. MIPS lgdO00 Microprocessor User's Manual, 1991.Google ScholarGoogle Scholar
  18. 18 Motorola, Inc. MC68020 32-Bit Microprocessor User's Manual, 2nd edition, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 19 Motorola, Inc. PowerPC 601 RISC Microprocessor User's Manual, 1993.Google ScholarGoogle Scholar
  20. 20 SPARC International, Inc., Menlo Park, CA. The SPARC Archztecture Manual, Version 8, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 21 Richard M. Stallman. Using and Porting GCC. The Free Software Foundation, Cambridge, MA, 1993.Google ScholarGoogle Scholar
  22. 22 Henry Warren. Predicting Ezecution Time on the IBM RISU System/6000. IBM, 1991. Preliminary Version.Google ScholarGoogle Scholar

Index Terms

  1. Division by invariant integers using multiplication

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 29, Issue 6
            June 1994
            360 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/773473
            Issue’s Table of Contents
            • cover image ACM Conferences
              PLDI '94: Proceedings of the ACM SIGPLAN 1994 conference on Programming language design and implementation
              August 1994
              360 pages
              ISBN:089791662X
              DOI:10.1145/178243

            Copyright © 1994 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 June 1994

            Check for updates

            Qualifiers

            • article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader