Contents    Page-10    Prev    Next    Page+10    Index   

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 with 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 in the x86 processor by a shift of 3 bits, which can be done for free by the instruction.

This form of code can be generated as one instruction on x86, assuming that i is in %rax:

   movsd  %xmm0,-208(%rbp,%rax,8)