

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CS 553 Compiler Construction โ Fall 2005 Homework # IRs, Program Optimization, and Alias Analysis Due October 7, 2005
Write your answers on another sheet of paper. Homework assignments are to be completed individually. Hand written submissions are fine, but they must be readable. Due at the beginning of class. Total points: 140, 5% of course grade
t = 0 loop: if (t>0) goto loopend j = j + c k = j* y = M[k] t = t - y goto loop loopend: j = j + 2 t = t + k if (j<n) goto loop
(a) What are the basic and derived induction variables in the example program? (b) Perform strength-reduction and induction-variable elimination on the example program and show the transformed program.
// code example 1 x = &y; p = &x; x = &z; **p =
// code example 2 q = &z; if () p = &q; else q = &y; **p =
// original code i = 0 x = 10 if (flag) goto L i = 11 v = i* goto L L1: i = x + 1 k = x + 1 d = i * 2 y = k * 2 L2: z = i * 2 x = i + 2 j = 0 loop: s = s + j