hw1soln - HW 1 -- Sample Solution Problem 1 See...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: HW 1 -- Sample Solution Problem 1 See optimization flags for gcc as examples. Problem 2 1. factorial: loadI 5 => r1 loadI 1 => r2 HEAD: nop loadI 1 => r3 cmp_LT r3, r1 => r4 cbr r4 => BODY, EXIT BODY: nop mult r2, r1 => r2 subI r1, 1 => r1 jumpI => HEAD EXIT: nop loadI 1020 => r5 store r2 => r5 output 1020 2. single basic block: (1) loadI 1024 => r0 loadI 5 => r1 storeAI r1 => r0, 0 loadI 7 => r2 storeAI r2 => r0, 4 add r1, r2 => r3 storeAI r3 => r0, 8 mult r3, r1 => r4 storeAI r4 => r0, 12 subI r4, 1 => r5 storeAI r5 => r0, 16 addI r5, 7 => r6 storeAI r6 => r0, 20 add r6, r1 => r7 store r7 => r0, 24 addI r7, 1 => r8 loadI 1020 => r9 store r8 => r9 output 1020 2. single basic block: (2) loadI 1024 => r0 loadI 5 => r1 storeAI r1 => r0, 0 loadI 7 => r2 storeAI r2 => r0, 4 add r1, r2 => r2 storeAI r2 => r0, 8 mult r2, r1 => r2 storeAI r2 => r0, 12 subI r2, 1 => r2 storeAI r2 => r0, 16 addI r2, 7 => r2 storeAI r2 => r0, 20 add r2, r1 => r2 store r2 => r0, 24 addI r2, 1 => r2 loadI 1020 => r1 store r2 => r1 output 1020 (3) same as (2). ...
View Full Document

This note was uploaded on 10/29/2010 for the course CS 198:415 taught by Professor Kremer,u. during the Spring '10 term at Rutgers.

Ask a homework question - tutors are online