Modulo in high-performance code: strength reduction for modulo-based array indexing in loops
Michiel Verloop, Thomas Koopman, Sven‐Bodo Scholz · 2023
Modulo operations on array indices provide a convenient means for specifying cyclic operations on arrays, such as rotations. A naive compilation of such operations involves integer divisions, which often can be avoided by partitioning or rearranging iteration spaces. This paper proposes an optimisation to this effect. The key idea is to systematically replace modulo operations within loops by partitioning such loops and replacing the modulo operations with division-free equivalents.