Homework 3: Partial Redundancy Elimination Course: CS 380C: Advanced Compiler Techniques (Fall 2007) Instructor: Keshav Pingali Assigned: Thursday, September 27, 2007 Due: Thursday, October 11, 2007, 11:59:59 PM (this is not the usual time) You can do this assignment in groups of two. 1. Objective ------------ The goal of this assignment is to perform Perform Partial Redundancy Elimination (PRE). In addition, there are some non-programming questions in section 4. Please answer them and turn in the solutions at the beginning of class on October 11. 2 Partial Redundancy Elimination (PRE) -------------------------------------- At this point, you have performed two data-flow analyses, liveness and constant propagation. For this assignment, perform PRE. PRE will be invoked similar to the optimizations performed in homework 2 (using command line flag -opt=pre). 3. Output --------- As usual, your compiler should accept 3-address code as input from stdin, and write output to stdout. Your compiler invoked by the script 'run.sh' should accept the following command line arguments. 1. -opt, a comma separated list of optimizations. The optimizations to support are dce, scp and pre. 2. -backend, the backend to be used to write output to. The optimizations to support are c, cfg and 3addr. 4. Answer these questions ------------------------- 1. Consider the domain D that is the powerset of the set {a,b,c}, in which elements are ordered by subset ordering, and {} is the least element. a) Draw a diagram of this partially ordered set. You do not have to show transitive edges. b) Write down a function D->D that is monotonic but not extensive. c) Write down a function D->D that is extensive but not monotonic. d) Write down a function D->D that is both extensive and monotonic. 2. If D is a domain (finite partially order set with a least element), and f:D->D and g:D->d are monotonic, show that the function h(x) = f(g(x)) is monotonic. 3. Let D be a domain (finite partially ordered set with a least element), and let f:D->D and g:D->D be monotonic and extensive functions. a) Show that any solution to the following system of simultaneous equations: x = f(x) x = g(x) is a solution to the equation x = f(g(x)) and vice versa. b) From this and the result of (2), argue that the system of simultaneous equations always has a least solution, and describe how to compute it. c) Do the results of (a) and (b) always hold if f and g are monotonic but not extensive? d) Do the results of (a) and (b) always hold if f and g are extensive but not monotonic? 5. Turning in your assignment ----------------------------- Download this tarball. http://www.cs.utexas.edu/users/pingali/CS380C/2007fa/assignments/assignment3/assignment3.tar.gz This is organized similar to homeworks 1 and 2. Your assignment should contain the following: 1. A single tar.gz file named hw3.tar.gz, which, when extracted, creates directory hw3. 2. The hw3 directory can contain sub-directories. 3. The hw3 directory should contain the following files: a. README - Please include your name(s) and UTEID(s) here. b. compile.sh - a script to compile your source code. c. run.sh - a script that runs your compiler. This script should read 3-address code as input from stdin and write output to stdout. The output is specified by the command line arguments described in section 3. The hw3 directory already exists with these files in the tarball you downloaded. Turn in your assignment by running the following commands on a UTCS Linux machine. $ # Go the parent directory of the hw3 directory. $ tar -zcvf hw3.tar.gz hw3 $ turnin --submit suriya cs380c-hw3 hw3.tar.gz $ turnin --list suriya cs380c-hw3 Please use turnin to submit your assignment. Only homeworks that are turned in using the procedure described above will be accepted. Turnin your answers to section 4, at the beginning of class on October 11. 6. Hints -------- 0. Start early :) 1. You can use the TA's solution from assignment 2. Do keep in mind that there are no claims are made about how that solution works. 2. Watch the clarifications page http://www.cs.utexas.edu/users/pingali/CS380C/2007fa/clarifications.html