Exercises in Optimisation 1. Given the following code, what are the sequences of quadruples that we can apply the constant folding optimisation? (Do not apply the optimisation, just identify the sequences). 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. (=,10,,b) (=,0,,i) (*,c,i,t1) (*,c,1,t4) (<,i,10,t0) (jfalse,14,,) (+,b,t1,t2) (*,t2,d,t3) (*,t4,d,t5) (=,t3,,a) (+,i,1,i) (+,t3,t5,t3) (jmp,5,,) (+,b,1,b) 2. Apply the constant folding and constant propagation optimisations to the quadruples in (1), producing an optimised set of quadruples. 3. Given the following code: int a = 2, b = 8, c = 4, d; for(i=0; i<5; i++){ a = a * (i* (b/c)); d = a * (i* (b/c)); } a. Generate the quadruples for this code b. Apply the optimisation: moving loop invariant code out of loop c. Apply reduction of force optimisation 4. Considere el siguiente conjunto de cuádruplas: INIT:(=, LOOP:··· (+, (*, ··· INCR:(+, 1, , j) t1, j, d, f, t2) t1) j, 2, j) ¿Cuál es el conjunto de cuádruplas resultante al aplicar el algoritmo para la optimización de reducción de fuerza en bucles contenido en el temario de la asignatura a la cuádrupla (*,j,f, t1)? a. Apply redundancy elimination optimisation b. Apply the Compile-Time Execution optimisation c. Would the result be different if optimisations (d) and (e) were applied first?