{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# ps3 - variables that could safely be assigned to the same...

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

ECE 468 & 573 Problem Set 3: Common sub-expression elimination and register allocation For the following problems, consider the following piece of three-address code: 1. A = 7; 2. B = A + 2; 3. C = A + B; 4. D = C + B; 5. A = D + C; 6. B = D + C; 7. E = A + B; 8. F = D + C; 9. G = E + F; 1. Show the result of performing Common Subexpression Elimination (CSE) on the above code. 2. Suppose E and C were aliased. How would that change the results of CSE? 3. If we were doing top-down register allocation, which variables would be put in regis- ters? Assume a machine with 3 registers. 4. For each instruction, show which variables are live immediately after the instruction . 5. How many registers would be needed to perform register allocation with no spilling? 6. Top down register allocation is inefficient for the above code, as there are some
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: variables that could safely be assigned to the same register. What are they? 7. Perform bottom-up register allocation on the code for a machine with three regis-ters. . Show what code would be generated for each 3AC instruction. When choosing registers to allocate, always allocate the lowest-numbered register available. When choosing registers to spill, choose the register holding a value that will be used farthest in the future (in case of a tie, choose the lowest-numbered register). 8. Draw the interference graph for the code. 9. (ECE 573 only) Perform register allocation via graph coloring for the code. If you need to spill, use the code-rewriting approach described in the notes. 1...
View Full Document

{[ snackBarMessage ]}