 
Summary: Strength Reduction of Integer Division and Modulo
Operations
Saman Amarasinghe, Walter Lee, Ben Greenwald \Lambda
M.I.T. Laboratory for Computer Science
Cambridge, MA 02139, U.S.A.
fsaman,walt,bengg@lcs.mit.edu
http://www.cag.lcs.mit.edu/raw
Abstract
Integer division, modulo, and remainder operations are expressive and useful operations. They are logical
candidates to express many complex data accesses such as the wraparound behavior in queues using ring buffers
and array address calculations in data distribution and cache locality compileroptimizations. Experienced appli
cation 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 analagous to strength reduction techiques used for multiplications. In addition to
some algebraic simplifications, we present a set of optimization techniques which eliminates division and modulo
operations that are functions of loop induction variables and loop constants. The optimizations rely on number
theory, integer programming and loop transformations.
1 Introduction
