Skip to main content

Strength Reduction of Integer Division and Modulo Operations

  • Conference paper
  • First Online:
Languages and Compilers for Parallel Computing (LCPC 2001)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2624))

Abstract

Integer division, modulo, and remainder operations are expressive and useful operations. They are logical candidates to express complex data accesses such as the wrap-around behavior in queues using ring buffers. In addition, they appear frequently in address computations as a result of compiler optimizations that improve data locality, perform data distribution, or enable parallelization. Experienced application programmers, however, avoid them because they are slow. Furthermore, while advances in both hardware and software have improved the performance of many parts of a program, few are applicable to division and modulo operations. This trend makes these operations increasingly detrimental to program performance.

This paper describes a suite of optimizations for eliminating division, modulo, and remainder operations from programs. These techniques are analogous to strength reduction techniques used for multiplications. In addition to some algebraic simplifications, we present a set of optimization techniques that eliminates division and modulo operations that are functions of loop induction variables and loop constants. The optimizations rely on algebra, integer programming, and loop transformations.

This research is funded in part by Darpa contract # DABT63-96-C-0036 and in part by an IBM Research Fellowship.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. R. Alverson. Integer Division Using Reciprocals. In Proceedings of the Tenth Symposium on Computer Arithmetic, Grenoble, France, June 1991.

    Google Scholar 

  2. S. Amarasinghe. Parallelizing Compiler Techniques Based on Linear Inequalities. In Ph.D Thesis, Stanford University. Also appears as Techical Report CSL-TR-97-714, Jan 1997.

    Google Scholar 

  3. C. Ancourt and F. Irigoin. Scanning Polyhedra with Do Loops. In Proceedings of the Third ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, pages 39–50, Williamsburg, VA, Apr. 1991.

    Google Scholar 

  4. M. Ancourt. Génération Automatique de Codes de Transfert pour Multiprocesseurs à Mémoires Locales. PhD thesis, Université Paris VI, Mar. 1991.

    Google Scholar 

  5. J. M. Anderson, S. P. Amarasinghe, and M. S. Lam. Data and Computation Transformations for Multiprocessors. In Proceedings of the Fifth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, pages 166–178, Santa Barbara, CA, July 1995.

    Google Scholar 

  6. R. Barua, W. Lee, S. Amarasinghe, and A. Agarwal. Maps: A Compiler-Managed Memory System for Raw Machines. In Proceedings of the 26th International Symposium on Computer Architecture, Atlanta, GA, May 1999.

    Google Scholar 

  7. J. Cocke and P. Markstein. Strength Reduction for Division and Modulo with Application to Accessing a Multilevel Store. IBM Journal of Research and Development, 24(6):692–694, November 1980.

    Article  Google Scholar 

  8. G. Dantzig. Linear Programming and Extensions. Princeton University Press, Princeton, NJ, 1963.

    MATH  Google Scholar 

  9. G. Dantzig and B. Eaves. Fourier-Motzkin Elimination and its Dual. Journal of Combinatorial Theory (A), 14:288–297, 1973.

    Article  MATH  MathSciNet  Google Scholar 

  10. R. Duffin. On Fourier’s Analysis of Linear Inequality Systems. In Mathematical Programming Study 1, pages 71–95. North-Holland, 1974.

    MathSciNet  Google Scholar 

  11. R. L. Graham, D. E. Knuth, and O. Patashnik. Concrete Mathematics. Addison-Wesley, Reading, MA, 1989.

    MATH  Google Scholar 

  12. T. Granlund and P. Montgomery. Division by Invariant Integers using Multiplication. In Proceedings of the SIGPLAN’ 94 Conference on Programming Language Design and Implementation, Orlando, FL, June 1994.

    Google Scholar 

  13. B. Greenwald. A Technique for Compilation to Exposed Memory Hierarchy. Master’s thesis, Massachusetts Institute of Technology, Department of Electrical Engineering and Computer Science, September 1999.

    Google Scholar 

  14. D. Magenheimer, L. Peters, K. Peters, and D. Zuras. Integer Multiplication and Division On the HP Precision Architecture. IEEE Transactions on Computers, 37:980–990, Aug. 1988.

    Article  Google Scholar 

  15. C. A. Moritz, M. Frank, W. Lee, and S. Amarasinghe. Hot Pages: Software Caching for Raw Microprocessors. Technical Memo LCS-TM-599, Laboratory for Computer Science, Massachusetts Institute of Technology, Sept 1999.

    Google Scholar 

  16. S. Oberman. Design Issues in High Performance Floating Point Arithmetic Units. PhD thesis, Stanford University, December 1996.

    Google Scholar 

  17. W. Pugh. The Omega test: A fast and practical integer programming algorithm for dependence analysis. In Proceedings of Supercomputing’ 91, Albuquerque, NM, Nov. 1991.

    Google Scholar 

  18. A. Schrijver. Theory of Linear and Integer Programming. John Wiley and Sons, Chichester, Great Britain, 1986.

    MATH  Google Scholar 

  19. M. B. Taylor. Design Decisions in the Implementation of a Raw Architecture Workstation. Master’s thesis, Massachusetts Institute of Technology, Department of Electrical Engineering and Computer Science, September 1999.

    Google Scholar 

  20. H. Williams. Fourier-Motzkin Elimination Extension to Integer Programming Problems. Journal of Combinatorial Theory, 21:118–123, 1976.

    Article  MATH  Google Scholar 

  21. R. Wilson, R. French, C. Wilson, S. Amarasinghe, J. Anderson, S. Tjiang, S.-W. Liao, C.-W. Tseng, M. Hall, M. Lam, and J. Hennessy. SUIF: An Infrastructure for Research on Parallelizing and Optimizing Compilers. ACM SIGPLAN Notices, 29(12), Dec. 1996.

    Google Scholar 

  22. M. E. Wolf. Improving Locality and Parallelism in Nested Loops. PhD thesis, Dept. of Computer Science, Stanford University, Aug. 1992.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2003 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Sheldon, J., Lee, W., Greenwald, B., Amarasinghe, S. (2003). Strength Reduction of Integer Division and Modulo Operations. In: Dietz, H.G. (eds) Languages and Compilers for Parallel Computing. LCPC 2001. Lecture Notes in Computer Science, vol 2624. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-35767-X_17

Download citation

  • DOI: https://doi.org/10.1007/3-540-35767-X_17

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-04029-3

  • Online ISBN: 978-3-540-35767-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics