gccint: loop-iv

1 
1 16.6 IV analysis on RTL
1 =======================
1 
1 The induction variable on RTL is simple and only allows analysis of
1 affine induction variables, and only in one loop at once.  The interface
1 is declared in 'cfgloop.h'.  Before analyzing induction variables in a
1 loop L, 'iv_analysis_loop_init' function must be called on L. After the
1 analysis (possibly calling 'iv_analysis_loop_init' for several loops) is
1 finished, 'iv_analysis_done' should be called.  The following functions
1 can be used to access the results of the analysis:
1 
1    * 'iv_analyze': Analyzes a single register used in the given insn.
1      If no use of the register in this insn is found, the following
1      insns are scanned, so that this function can be called on the insn
1      returned by get_condition.
1    * 'iv_analyze_result': Analyzes result of the assignment in the given
1      insn.
1    * 'iv_analyze_expr': Analyzes a more complicated expression.  All its
1      operands are analyzed by 'iv_analyze', and hence they must be used
1      in the specified insn or one of the following insns.
1 
1  The description of the induction variable is provided in 'struct
1 rtx_iv'.  In order to handle subregs, the representation is a bit
1 complicated; if the value of the 'extend' field is not 'UNKNOWN', the
1 value of the induction variable in the i-th iteration is
1 
1      delta + mult * extend_{extend_mode} (subreg_{mode} (base + i * step)),
1 
1  with the following exception: if 'first_special' is true, then the
1 value in the first iteration (when 'i' is zero) is 'delta + mult *
1 base'.  However, if 'extend' is equal to 'UNKNOWN', then 'first_special'
1 must be false, 'delta' 0, 'mult' 1 and the value in the i-th iteration
1 is
1 
1      subreg_{mode} (base + i * step)
1 
1  The function 'get_iv_value' can be used to perform these calculations.
1