Contents    Page-10    Prev    Next    Page+10    Index   

Induction Variable Transformation

Some compilers transform the induction variable (loop index) to allow simplified subscripting expressions:


  for i:=1 to 1000 do ... x[i]

    (:= I 1)
    (LABEL 1)
    (IF (<= I 1000)
        (PROGN ... (AREF X (+ -8 (* 8 I)))
               (:= I (+ I 1))
               (GOTO L1)))
might be transformed to:

    (:= I' 0)
    (LABEL 1)
    (IF (<= I' 7992)
        (PROGN ... (AREF X I')
               (:= I' (+ I' 8))
               (GOTO L1)))
Note that the loop index has no meaning outside the loop and may not have storage assigned to it. Some machines can automatically increment an index register after it is used (called postincrement).