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.
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
This research is funded in part by Darpa contract # DABT63-96-C-0036 and in part by an IBM Research Fellowship.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
R. Alverson. Integer Division Using Reciprocals. In Proceedings of the Tenth Symposium on Computer Arithmetic, Grenoble, France, June 1991.
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.
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.
M. Ancourt. Génération Automatique de Codes de Transfert pour Multiprocesseurs à Mémoires Locales. PhD thesis, Université Paris VI, Mar. 1991.
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.
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.
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.
G. Dantzig. Linear Programming and Extensions. Princeton University Press, Princeton, NJ, 1963.
G. Dantzig and B. Eaves. Fourier-Motzkin Elimination and its Dual. Journal of Combinatorial Theory (A), 14:288–297, 1973.
R. Duffin. On Fourier’s Analysis of Linear Inequality Systems. In Mathematical Programming Study 1, pages 71–95. North-Holland, 1974.
R. L. Graham, D. E. Knuth, and O. Patashnik. Concrete Mathematics. Addison-Wesley, Reading, MA, 1989.
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.
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.
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.
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.
S. Oberman. Design Issues in High Performance Floating Point Arithmetic Units. PhD thesis, Stanford University, December 1996.
W. Pugh. The Omega test: A fast and practical integer programming algorithm for dependence analysis. In Proceedings of Supercomputing’ 91, Albuquerque, NM, Nov. 1991.
A. Schrijver. Theory of Linear and Integer Programming. John Wiley and Sons, Chichester, Great Britain, 1986.
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.
H. Williams. Fourier-Motzkin Elimination Extension to Integer Programming Problems. Journal of Combinatorial Theory, 21:118–123, 1976.
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.
M. E. Wolf. Improving Locality and Parallelism in Nested Loops. PhD thesis, Dept. of Computer Science, Stanford University, Aug. 1992.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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