Better Array References


    (AREF X (+ -8 (* 8 I)))

A better way generate the array reference is to:

  1. combine as many constants as possible
  2. replace the multiply by a shift
Note that in the expression (+ -8 (* 8 I)) there is an additive constant of -8 and that the multiply by 8 can be done by a shift of 3 bits.

        add     %fp,-816,%l1    !  + -816
        ld      [%fp-8],%l2     !  i 
        sll     %l2,3,%l2       !  shift left 3
        ldd     [%l1+%l2],%f2   !  x[]
This form of code is 4 instructions, compared to 7 for the other form.

Contents    Page-10    Prev    Next    Page+10    Index