Loop Tree and Induction Variables - Pop, Sebastian; Cohen, Albert (SSA-based Compiler Design, 2022)
Induction variables refer to a wide class of inductive definitions, where the sequence of values taken by a variable follows a regular pattern. The typical case is that of a loop counter. More generally, induction variables are associated with affine, geometric, or otherwise statically predictable progressions in loops. The purpose of the induction variable analysis is to provide a characterization of such sequences. There are numerous applications, from the detection of parallel loops to optimizations such as loop-invariant code motion, strength reduction, eliminating dependencies, and evaluating the number of iterations of a while loop. This chapter focuses particularly on the analysis and classification of induction variables in the presence of complex, low-level control flow (gotos, multiple loop exits, etc.). It describes the algorithm underlying the analysis of “scalar evolutions” in the GCC and LLVM compilers.