Elimination common local optimization within a block

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: code. Global optimization across blocks. Global register allocation. Strength reduction. Example: replace integer Strength multiply by 2k with shift left. multiply Unnecessary instructions. A value not used in Unnecessary the later part of program may not be stored in memory (eliminate sw). memory Spring 2014, Feb 10 . . . Spring ELEC 5200-001/6200-001 Lecture 4 9 MIPS Compiler Example C code: f = (g+h) – (i+j) Compiler assigns variables f, g, h, i and j to Compiler registers $s0, $s1, $s2, $s3 and $s4 registers Uses two temporary registers, $t0 and $t1, to Uses produce the following MIPS assembly code: produce add $t0, $s1, $s2 add $t1, $s3, $s4 sub $s0, $t0, $t1 Spring 2014, Feb 10 . . . Spring # reg $t0 contains g+h # reg $t1 contains i+j # reg $s0 = $t0 – $t1 reg $t0 = (g+h) – (i+j) ELEC 5200-001/6200-001 Lecture 4 10 Registers $sp and $gp $sp Stack Temp. registers saved before procedure call $s0-$s7 saved in stack by procedure Dynamic data heap $gp Static data Global variables in program Machine code (text) pc Reserved 0 Spring 2014, Feb 10 . . . Spring ELEC 5200-001/6200-001 Lecture 4 11 Register $fp (Fr...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online