hw2 - EE108B Spring 2003-2004 Prof. Kozyrakis Homework #2...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: EE108B Spring 2003-2004 Prof. Kozyrakis Homework #2 Due Tues. April 27, 5 PM in Gates 310 Work in groups of 3 students, but turn in only one HW per group. 1. (11 points) The following C program is compiled into MIPS objects with no optimization and with O2 optimization. int A[100], B[100]; main() { int i; int c = 10; for (i=0; i < 100; i++) A[i] = B[i] + c; } Unoptimized Code Optimized with O2 0x0: lui gp, 0x4: addiu gp, gp, 0x8: addu gp, gp, t9 0xc: addiu sp, sp, -24 0x10: sw gp, 0(sp) 0x14: sw fp, 20(sp) 0x18: sw gp, 16(sp) 0x1c: move fp, sp 0x20: li v0, 10 0x24: sw v0, 12(fp) 0x28: sw zero, 8(fp) 0x2c: lw v0, 8(fp) 0x30: slti v1, v0, 100 0x34: bne v1, zero, 0x3c 0x38: b 0x88 0x3c: lw v0, 8(fp) 0x40: move v1, v0 0x44: sll v0, v1, 2 0x48: lw v1, 0(gp) 0x4c: addu v0, v0, v1 0x50: lw v1, 8(fp) 0x54: move a0, v1 0x58: sll v1, a0, 2 0x5c: lw a0, 0(gp) 0x60: addu v1, v1, a0 0x64: lw a0, 0(v1) 0x68: lw v1, 12(fp) 0x6c: addu a0, a0, v1 0x70: sw a0, 0(v0) 0x74: lw v1, 8(fp) 0x78: addiu v0, v1, 1 0x7c: move v1, v0 0x80: sw v1, 8(fp) 0x84: b 0x2c 0x88: move sp, s8 0x0: lui gp, 0 0x4: addiu gp, gp, 0x8: addu gp, gp, t9 0xc: li a2, 10 0x10: move a1, zero 0x14: lw a0, 0(gp) 0x18: lw v1, 0(gp) 0x1c: lw v0, 0(v1) 0x20: addiu v1, v1, 4 0x24: addiu a1, a1, 1 0x28: addu v0, v0, a2 0x2c: sw v0, 0(a0) 0x30: slti v0, a1, 100 0x34: addiu a0, a0, 4 0x38: bne v0, zero, 0x1c 0x3c: jr ra 1 EE108B Spring 2003-2004 Prof. Kozyrakis 0x8c: lw fp, 20(sp) 0x90: addiu sp, sp, 24 0x94: jr ra a. (5 points) Please identify the optimizations used by the compiler to transform...
View Full Document

This note was uploaded on 11/18/2011 for the course EE 108A taught by Professor Dally during the Spring '04 term at Stanford.

Page1 / 5

hw2 - EE108B Spring 2003-2004 Prof. Kozyrakis Homework #2...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online