Module 15: Reaching Definition
  Lecture 30: Analysis
 


Detection of Induction Variables

Input: A loop L with reaching definition information and loop invariant computation information
Output: A set of induction variables. Associated with each induction variable j is a triple (i, c, d) such that j=c*i+d. i is assumed to be basic induction variable, and j is said to belong to family of i.

  1. Find all basic induction variables of L (using loop invariant information). Each basic induction variable has a triple (i, 1, 0).
  2. Search for variable k with single assignment to k within L having one of the following forms:
    k=j*const, k=j/const, k=j ± const
    where j is an induction variable.
  1. If j is basic induction variable then k is in family of j. if j is not basic and is in family of i then
    • There is no assignment to i between j and k
    • No definition of j outside L reaches k
  2. Modify instructions computing induction variable such that ± are used rather than multiplication (strength reduction).

Strength Reduction

Consider each basic induction variable. For every induction variable j in family of i with triple (i, c, d)

  1. Create a new variable s
  2. Replace all assignments to j by j=s
  3. Immediately after each assignment i=i+n append s=s+c*n
    Place s in the family of i with triple (i,c,d)
  4. Initialize s to s=c*i+d in the pre-header
    Eliminate induction variables

Pointers

A := B + C
*P := D
F := *P
E := B+C

No definitions of B or C.
Is B+C available at E := B+C
depends whether ∗P changes B or C

Safe Assumption : Indirect assignment can change any variable, indirect use can use any name
Therefore,

  • More live variable and reaching definitions than realistic.
  • Fewer available expressions than realistic