20.04.2013 Views

Spring 2011 CSCI 565 - Compiler Design

Spring 2011 CSCI 565 - Compiler Design

Spring 2011 CSCI 565 - Compiler Design

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Pedro Diniz<br />

pedro@isi.edu<br />

DO J = 1, N<br />

A[I,J] = A[I,J] + B[I,J]<br />

END DO<br />

<strong>CSCI</strong> <strong>565</strong> - <strong>Compiler</strong> <strong>Design</strong><br />

• Sophisticated: Move common calculations out of loop<br />

R1 = I x floatsize<br />

c = len 1 x floatsize ! Compile-time constant<br />

R2 = baseA 0 + R1<br />

R3 = baseB 0 + R1<br />

DO J = 1, N<br />

a = J x c<br />

R4 = R2 + a<br />

R5 = R3 + a<br />

MEM(R4) = MEM(R4) + MEM(R5)<br />

END DO<br />

<strong>Spring</strong> <strong>2011</strong><br />

Array Address Calculations in a Loop

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!