Next: , Previous: Scalar evolutions, Up: Loop Analysis and Representation

11.6 IV analysis on RTL

The induction variable on RTL is simple and only allows analysis of affine induction variables, and only in one loop at once. The interface is declared in cfgloop.h. Before analyzing induction variables in a loop L, iv_analysis_loop_init function must be called on L. After the analysis (possibly calling iv_analysis_loop_init for several loops) is finished, iv_analysis_done should be called. The following functions can be used to access the results of the analysis:

The description of the induction variable is provided in struct rtx_iv. In order to handle subregs, the representation is a bit complicated; if the value of the extend field is not UNKNOWN, the value of the induction variable in the i-th iteration is


with the following exception: if first_special is true, then the value in the first iteration (when i is zero) is delta + mult * base. However, if extend is equal to UNKNOWN, then first_special must be false, delta 0, mult 1 and the value in the i-th iteration is

     subreg_{mode} (base + i * step)

The function get_iv_value can be used to perform these calculations.