(b). Identify all basic blocks in your three address code. B1: 1; B2: 2; B3: 3,4,5,6; B4: 7,8,9; B5: 10; B6: 11; B7: 12,13,14; B8: 15;
|
|
- Corey Small
- 5 years ago
- Views:
Transcription
1 (a). Translate the program into three address code as defined in Section 6.2, dragon book. (1) i := 2 (2) if i > n goto (7) (3) a[i] := TRUE (4) t2 := i+1 (5) i := t2 (6) goto (2) (7) count := 0 (8) s := sqrt(n) (9) i := 2 (10) if i > s goto (23) (11) if a[i]!= TRUE goto (20) (12) t4 := count +1 (13) count := t4 (14) j := 2*i (15) if j > n goto (20) (16) a[j] := FALSE (17) t6 := j+1 (18) j := t6 (19) goto (15) (20) t7 := i+1 (21) i := t7 (22) goto (10) (23)exit (b). Identify all basic blocks in your three address code. B1: 1; B2: 2; B3: 3,4,5,6; B4: 7,8,9; B5: 10; B6: 11; B7: 12,13,14; B8: 15;
2 B9: 16,17,18,19; B10: 20,21,22; B11: 23 (c). Build the flow graph for the three address code. (1) i := 2 B1 (2) if i > n goto (7) B2 (3) a[i] := TRUE (4) t2 := i+1 (5) i := t2 (6) goto (2) B3 (7) count := 0 (8) s := sqrt(n) (9) i := 2 B4 (10) if i > s goto (23) B5 (11) if a[i]!= TRUE goto (20) B6 (12) t4 := count +1 (13) count := t4 (14) j := 2*i B7 (15) if j > n goto (20) B8 (16) a[j] := FALSE (17) t6 := j+1 (18) j := t6 (19) goto (15) B9 (20) t7 := i+1 (21) i := t7 (22) goto (10) B10 (23)exit B11
3 (d). Build the dominator tree and identify the back edges in your flow graph in (c) Flow graph Dominator tree Back edges are (10,5), (9,8), (3,2) (shown as the red edge of the flow graph). (e). Find the entry node and the set of nodes in the natural loop associated with each back edge identified in (d). back edge (10,5): entry code 5 code sets {5,6,7,8,9,10} back edge (9,8): entry code 8 code sets {8,9} back edge (3,2): entry code 2 code sets {2,3}
4 (a) Compute Gen and Kill sets for each block in the flow graph. Gen[B1] = {(1),(2)} Kill[B1] = {(8),(10),(11)} Gen[B2] = {(3),(4)} Kill[B2] = {(5),(6)} Gen[B3] = {(5)} Kill[B3] = {(4),(6)} Gen[B4] = {(6),(7)} Kill[B4] = {(4),(5),(9)} Gen[B5] = {(8),(9)} Kill[B5] = {(2),(7),(11)} Gen[B6] = {(10),(11)} Kill[B6] = {(1),(2),(8)} (b) Compute the In and Out sets for each block in the flow graph. Initialization: In[B1] = Out[B1] = Gen[B1] = {(1),(2)} In[B2] = Out[B2] = Gen[B2] = {(3),(4)} In[B3] = Out[B3] = Gen[B3] = {(5)} In[B4] = Out[B4] = Gen[B4] = {(6),(7)} In[B5] =
5 Out[B5] = Gen[B5] = {(8),(9)} In[B6] = Out[B6] = Gen[B6] = {(10),(11)} Update: 1. In[B1] = Out[B1] = Gen[B1] (In[B1]-Kill[B1]) = {(1),(2)} In[B2] = Out[B1] Out[B5] ={(1),(2), (8),(9)} Out[B2] = Gen[B2] (In[B2]-Kill[B2]) = {(1),(2), (3),(4), (8),(9)} In[B3] = Out[B2] Out[B4] ={(1),(2),(3),(4),(6),(7),(8),(9)} Out[B3] = Gen[B3] (In[B3]-Kill[B3]) = {(1),(2),(3),(5),(7),(8),(9)} In[B4] = Out[B3] ={(1),(2),(3),(5),(7),(8),(9)} Out[B4] = Gen[B4] (In[B4]-Kill[B4]) = {(1),(2),(3),(6),(7),(8)} In[B5] = Out[B3] = {(1),(2),(3),(5),(7),(8),(9)} Out[B5] = Gen[B5] (In[B5]-Kill[B5]) = {(1),(3),(5),(8),(9)} In[B6] = Out[B5] ={(1),(3),(5),(8),(9)} Out[B6] = Gen[B6] (In[B6]-Kill[B6]) = {(3),(5),(9),(10),(11)} 2. In[B1] = Out[B1] = Gen[B1] (In[B1]-Kill[B1]) = {(1),(2)} In[B2] = Out[B1] Out[B5] ={(1),(2), (5),(6),(8),(9)} Out[B2] = Gen[B2] (In[B2]-Kill[B2]) = {(1),(2), (3),(4), (8),(9)} In[B3] = Out[B2] Out[B4] ={(1),(2), (3),(4), (6),(7),(8),(9)} Out[B3] = Gen[B3] (In[B3]-Kill[B3]) = {(1),(2), (3),(5),(7),(8),(9)} In[B4] = Out[B3] ={(1),(2), (3),(5),(7),(8),(9)} Out[B4] = Gen[B4] (In[B4]-Kill[B4]) = {(1),(2),(3),(6),(7),(8)} In[B5] = Out[B3] = {(1),(2),(3),(5),(7),(8),(9)} Out[B5] = Gen[B5] (In[B5]-Kill[B5]) = {(1),(3),(5),(8),(9)} In[B6] = Out[B5] ={(1),(3),(5),(8),(9)} Out[B6] = Gen[B6] (In[B6]-Kill[B6]) = {(3),(5),(9),(10),(11)} Reached fixed point (c) Perform constant propagation and constant folding. B1: In: no definition of a and b Out: a = 1; b =2 B2: In: a = 1; b = *; c = *; d = *; e = *; Out: a = 1; b = *; c = *; d = *; e = *; B3: In: a = 1; b = *; c = *; d = *; e = *; Out: a = 1; b = *; c = *; d = *; e = *; B4: In: a = 1; b = *; c = *; d = *; e = *; Out: a = 1; b = *; c = *; d = *; e = *; B5: In: a = 1; b = *; c = *; d = *; e = *; Out: a = 1; b = *; c = *; d = *; e = *;
6 B6: In: a = 1; b = *; c = *; d = *; e = *; Out: a = *; b = *; c = *; d = *; e = *; (d) Perform common sub expression elimination. Update Gen and Kill sets: Gen[B1] = Kill[B1] = Gen[B2] = {c = a+b, d = c-a} Kill[B2] = {d = b+d, a = b*d, b = a-d, e = c-a} Gen[B3] = {d = b+d} Kill[B3] = {a = b*d, b = a-d, d = a+b} Gen[B4] = {d = a+b, e = e+1} Kill[B4] = {d = b+d, a = b*d, b = a-d} Gen[B5] = {b = a+b, e = c-a} Kill[B5] = {c = a+b, d = b+d, d = a+b, e = e+1, a = b*d} Gen[B6] = {a = b*d, b = a-d} Kill[B6] = {c = a+b, d = c-a, d = b+d, d = a+b, b = a+b, e = c-a} Update In and Out sets In[B1] = Out[B1] = Gen[B1] (In[B1]-Kill[B1]) = In[B2] = Out[B1] Out[B5] = Out[B2] = Gen[B2] (In[B2]-Kill[B2]) = {c = a+b, d = c-a} In[B3] = Out[B2] Out[B4] = Out[B3] = Gen[B3] (In[B3]-Kill[B3]) = {d = b+d} In[B4] = Out[B3] = { d = b+d } Out[B4] = Gen[B4] (In[B4]-Kill[B4]) = {d = a+b, e = e+1 } In[B5] = Out[B3] = { d = b+d } Out[B5] = Gen[B5] (In[B5]-Kill[B5]) = {b = a+b, e = c-a} In[B6] = Out[B5] = {b = a+b, e = c-a} Out[B6] = Gen[B6] (In[B6]-Kill[B6]) = {a = b*d, b = a-d} Final In and Out sets In[B1] = Out[B1] = Gen[B1] (In[B1]-Kill[B1]) = In[B2] = Out[B1] Out[B5] = Out[B2] = Gen[B2] (In[B2]-Kill[B2]) = {c = a+b, d = c-a} In[B3] = Out[B2] Out[B4] = {c,d = a+b} Out[B3] = Gen[B3] (In[B3]-Kill[B3]) = {d = b+d, c,d = a+b } In[B4] = Out[B3] ={ d = b+d, c,d = a+b } Out[B4] = Gen[B4] (In[B4]-Kill[B4]) = { c,d = a+b, e = e+1} In[B5] = Out[B3] = { d = b+d, c = a+b } Out[B5] = Gen[B5] (In[B5]-Kill[B5]) = {b,c,d = a+b, e = c-a} In[B6] = Out[B5] = {b,c,d = a+b, e = c-a} Out[B6] = Gen[B6] (In[B6]-Kill[B6]) = {a = b*d, b = a-d} Do common sub expression elimination:
7 Because c = a+b is in In[B4] set and d = a+b is in B4, for c = a+b in B2 we can replace c = a+b with t1 = a+b; c = t1 and in B4 we can replace d = a+b with d = t1 ; Because c = a+b is in In[B5] set and b = a+b is in B5, for c = a+b in B2 we can replace c = a+b with t1 = a+b; c = t1 and in B5 we can replace b = a+b with b = t1 ; 3. Consider the following flow graph. (a) Identify and mark define-use links within the loop based on data flow analysis results (based on the In and Out sets). You need to consider the block level define-use relations as well as define-use relations within the block.
8 (b) Identify all the loop invariants based on the define-use links computed in (b). Assume that all the loop invariants can be moved out of the loop. So you need to find loop invariants repetitively till a fixed point is reached. In each round, you need to pretend to move out those loop invariants you found in the previous rounds. Round 1: B2: Statement N = 100, N is loop invariant, move N = 100 out of the loop; Statement M = 1000, M is loop invariant, move M = 1000 out of the loop; Statement s1 = 2, s1 is loop invariant, move s1 = 2 out of the loop; B3: Statement s1 = 1, s1 is loop invariant, move s1 = 1 out of the loop; B4: Statement s2 = 2, s2 is loop invariant, move s2 = 2 out of the loop; Round2: B2: move statement t2 = t1+s1 out of the loop; B7: Statement M = M-1, M is loop invariant, move M = M-1 out of the loop; Round3: B3: move t2 = t2-n out of the loop; Round4: B4: move t3 = t2+s2 out of the loop; Round 5: B5: move t3 = t3-n out of the loop
9 Round6: B6: move d = A[t1] + A[t2] out of the loop Round7: B7: move d = d-m out of the loop Round8: B8: move A[t3] = d out of the loop (c) For each loop invariant, determine whether it can actually be moved out of the loop. If so, move it out of the loop. If not, state the reason why it cannot be moved out. Generate the new code after code motion.
10 Round 1: B2: Statement N = 100, N is loop invariant, move N = 100 out of the loop; Can be moved out of the loop. Statement M = 1000, M is loop invariant, move M = 1000 out of the loop; Cannot be moved out of the loop, because there is other definition of M in the loop, say M = M-1 in B7. Statement s1 = 2, s1 is loop invariant, move s1 = 2 out of the loop; Cannot be moved out of the loop, because there is other definition of s1 in the loop, say s1 = 1 in B3. B3: Statement s1 = 1, s1 is loop invariant, move s1 = 1 out of the loop; Cannot be moved out of the loop, because there is other definition of s1 in the loop, say s1 = 2 in B2. B4: Statement s2 = 2, s2 is loop invariant, move s2 = 2 out of the loop; Can be moved out of the loop. Round2: B2: move statement t2 = t1+s1 out of the loop; Cannot be moved out of the loop, because s1 is defined inside the loop. B7: Statement M = M-1, M is loop invariant, move M = M-1 out of the loop; Cannot be moved out of the loop, because there is other definition of M in the loop, say M = 1000 in B2. Round3: B3: move t2 = t2-n out of the loop; Cannot be moved out of the loop, because t2 is defined inside the loop. Round4: B4: move t3 = t2+s2 out of the loop; Cannot be moved out of the loop, because t2 is defined inside the loop. Round 5: B5: move t3 = t3-n out of the loop Cannot be moved out of the loop, because t3 is defined inside the loop. Round6: B6: move d = A[t1] + A[t2] out of the loop Cannot be moved out of the loop, because t2 is defined inside the loop. Round7: B7: move d = d-m out of the loop Cannot be moved out of the loop, because d and M is defined inside the loop. Round8: B8: move A[t3] = d out of the loop Cannot be moved out of the loop, because t3 is defined inside the loop. The new code generated after code motion:
11 (a) Perform copy propagation. You need to do necessary data flow analysis to make sure that the propagation can be done correctly. (added additional rule: A[j] := y op z shall be killed if the current block contains x := A[i], that is, we should add A[j] := y op z in the kill[b] if B contains x:=a[i] ) Gen[1] = kill[1] = ; In[1]=Out[1]= Gen[2] = kill[2] = ; In[2]=Out[2]= Gen[3] = {3}, Kill[3] = {10,14}; In[3] =, Out[3] = {3}; Gen[4] = {4}, Kill[4] = ; In[4] = {3}, Out[4] = {3,4} Gen[5] = kill[5] = ; In[5] = {3,4}, Out[5] = {3,4} Gen[6] = kill[6] = ; In[6] = {3,4}, Out[6] = {3,4}
12 Gen[7] = {7}, Kill[7] = {10,14}; In[7] = {3,4}, Out[7] = {3,4,7} Gen[8] = kill[8] = ; In[8] = {3,4,7}, Out[8] = {3,4,7} Gen[9] = kill[9] = ; In[9] = {3,4,7}, Out[9] = {3,4,7} Gen[10] = {10}, Kill[10] = {3,7,14}; In[10] = {3,4,7}, Out[10] = {4,10} Gen[11] = {11}, Kill[10] = ; In[11] = {4,10}, Out[11] = {4,10,11} Gen[12] = kill[12] = ; In[12] = {4,10,11}, Out[12] = {4,10,11} Gen[13] = kill[13] = ; In[13] = {4,10,11}, Out[13] = {4,10,11} Gen[14] = {14}, Kill[14] = {3,10}; In[14] = {4,10,11}, Out[14] = {4,11,14} Statement 6 uses t3, statement 4 reaches statement 6, statement 4 is the only definition for t3 that reaches statement 6, no definition of j on the path from 4 to 6, thus we can substitute the use of t3 by j in 6. Statement 13 uses t9, 11 reaches 13, 11 is the only definition of t9 that reaches 13, no definition of j on the path from 11 to 13, thus we can substitute the use of t9 by j in 13. (b) Perform dead code elimination. You need to do necessary analysis to make sure that the elimination can be done correctly. Also, assume that after the basic block, A[i], for all i, are alive and no other variables are alive. After performing the copy propagation, the three address code should be revised as following: (1) t1 = j 1 (2) t2 = 4 * t1 (3) temp = A[t2] (4) t3 = j (5) t4 = j + 1 (6) t5 = 4 * j (7) t6 = A[t5] (8) t7 = j 1 (9) t8 = 4 * t7 (10) A[t8] = t6 (11) t9 = j (12) t10 = j + 1 (13) t11 = 4 * j (14) A[t11] = temp We just consider index of A[i], which is i, when come across A[i]. Let P(i) denotes the live set after statement i, for 1<=i<=14, then: P A = P(14) = P(13) = {P(14)} {temp, t11} = {temp,t11} P(12) = {P(13) t11} {j} = {temp, j} P(11) = {P(12) - t10} {j} = {temp, j} P(10) = {P(11) t9} {j} = { temp, j} P(9) = {P(10)} {t6, t8} = { temp, t6, t8, j} P(8) = {P(9) t8} {t7} = { temp, t6, t7, j} P(7) = {P(8) t7} {j} = { temp, t6, j} P(6) = {P(7) t6} {t5} = { temp, t5, j} P(5) = {P(6) t5} {j} = { temp, j} P(4) = {P(5) t4} {j} = { temp, j}
13 P(3) = {P(4) t3} {j} = { temp, j} P(2) = {P(3) temp} {t2} = {t2, j} P(1) = {P(2) t2} {t1} = {t1, j} P B = {P(2) t1} {j} = {j} 12 can be eliminated because t10 is defined in 12, but t10 is not included in P(12) = {t2,j}. 11 can be eliminated because t9 is defined in 11, but t9 is not included in P(11) = {t2,j}. 5 can be eliminated because t4 is defined in 5, but t4 is not included in P(5) = {t2, j} 4 can be eliminated because t3 is defined in 4, but t3 is not included in P(4) = {t2, j} Definition of t1 in loop B2 is: t1 := t1+2, also within B2, t2 is defined as a linear function of t1: t2 := t1*3+5, t1 and t2 are only defined once in B2. Thus we can perform strength reduction for induction variables t1 and t2: Create a new variable st2 immediately before the entry of B2; Initialize st2 by using st2 := t1*3+5 ; Add st2 := st2 + 6 immediately after t1 := t1+2 ; Replace t2 := t1*3+5 by t2 := s2 ; The revised code is as following:
14 t1 := 0 read (x, y) st2 := t1*3+5 a := x * t1 t2 := st2 b := y * t2 c := t2 + 5 d := c * b t1 := t1 + 2 st2 := st2 + 6 There is no more induction variables can be found.
Topic-I-C Dataflow Analysis
Topic-I-C Dataflow Analysis 2012/3/2 \course\cpeg421-08s\topic4-a.ppt 1 Global Dataflow Analysis Motivation We need to know variable def and use information between basic blocks for: constant folding dead-code
More information3/11/18. Final Code Generation and Code Optimization
Final Code Generation and Code Optimization 1 2 3 for ( i=0; i < N; i++) { base = &a[0]; crt = *(base + i); } original code base = &a[0]; for ( i=0; i < N; i++) { crt = *(base + i); } optimized code e1
More informationDataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) {
-4 Lecture Dataflow Analysis Basic Blocks Related Optimizations Copyright Seth Copen Goldstein 00 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation Common
More informationLecture 5 Introduction to Data Flow Analysis
Lecture 5 Introduction to Data Flow Analysis I. Structure of data flow analysis II. III. IV. Example 1: Reaching definition analysis Example 2: Liveness analysis Framework Phillip B. Gibbons 15-745: Intro
More informationData Flow Analysis (I)
Compiler Design Data Flow Analysis (I) Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential
More informationCompiler Design. Data Flow Analysis. Hwansoo Han
Compiler Design Data Flow Analysis Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential
More informationDataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation
-74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation
More informationAdventures in Dataflow Analysis
Adventures in Dataflow Analysis CSE 401 Section 9-ish Jack Eggleston, Aaron Johnston, & Nate Yazdani Announcements - Code Generation due Announcements - Code Generation due - Compiler Additions due next
More informationLecture 4 Introduc-on to Data Flow Analysis
Lecture 4 Introduc-on to Data Flow Analysis I. Structure of data flow analysis II. Example 1: Reaching defini?on analysis III. Example 2: Liveness analysis IV. Generaliza?on 15-745: Intro to Data Flow
More informationData flow analysis. DataFlow analysis
Data flow analysis DataFlow analysis compile time reasoning about the runtime flow of values in the program represent facts about runtime behavior represent effect of executing each basic block propagate
More informationCSC D70: Compiler Optimization Dataflow-2 and Loops
CSC D70: Compiler Optimization Dataflow-2 and Loops Prof. Gennady Pekhimenko University of Toronto Winter 2018 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip Gibbons
More informationDepartment of Computer Science and Engineering, IIT Kanpur, INDIA. Code Optimization. Sanjeev K Aggarwal Code Optimization 1 of I
Code Optimization Sanjeev K Aggarwal Code Optimization 1 of 23 2007-08-I Code Optimization int a,b,c,d ldw a,r1 add r1,r2,r3 c = a+b ldw b,r2 add r3,1,r4 d = c+1 add r1,r2,r3 stw r3,c ldw c,r3 add r3,1,r4
More informationCS 553 Compiler Construction Fall 2006 Homework #2 Dominators, Loops, SSA, and Value Numbering
CS 553 Compiler Construction Fall 2006 Homework #2 Dominators, Loops, SSA, and Value Numbering Answers Write your answers on another sheet of paper. Homework assignments are to be completed individually.
More informationMIT Loop Optimizations. Martin Rinard
MIT 6.035 Loop Optimizations Martin Rinard Loop Optimizations Important because lots of computation occurs in loops We will study two optimizations Loop-invariant code motion Induction variable elimination
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 8.5 Reaching definitions Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Admin issues Brief reminder: Code review takes place today @ 15:15 You
More informationWhat is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed
Another Form of Data-Flow Analysis Propagation of values for a variable reference, where is the value produced? for a variable definition, where is the value consumed? Possible answers reaching definitions,
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 8.6 Live variables Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Last lecture Definition: A variable V is live at point P if there is a path
More informationHeaps Induction. Heaps. Heaps. Tirgul 6
Tirgul 6 Induction A binary heap is a nearly complete binary tree stored in an array object In a max heap, the value of each node that of its children (In a min heap, the value of each node that of its
More informationDataflow analysis. Theory and Applications. cs6463 1
Dataflow analysis Theory and Applications cs6463 1 Control-flow graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows
More informationGeneralizing Data-flow Analysis
Generalizing Data-flow Analysis Announcements PA1 grades have been posted Today Other types of data-flow analysis Reaching definitions, available expressions, reaching constants Abstracting data-flow analysis
More informationReading: Chapter 9.3. Carnegie Mellon
I II Lecture 3 Foundation of Data Flow Analysis Semi-lattice (set of values, meet operator) Transfer functions III Correctness, precision and convergence IV Meaning of Data Flow Solution Reading: Chapter
More informationTopics on Compilers
Assignment 2 4541.775 Topics on Compilers Sample Solution 1. Test for dependences on S. Write down the subscripts. Which positions are separable, which are coupled? Which dependence test would you apply
More informationScalar Optimisation Part 2
Scalar Optimisation Part 2 Michael O Boyle January 2014 1 Course Structure L1 Introduction and Recap 4-5 lectures on classical optimisation 2 lectures on scalar optimisation Last lecture on redundant expressions
More informationAdvanced Analysis of Algorithms - Midterm (Solutions)
Advanced Analysis of Algorithms - Midterm (Solutions) K. Subramani LCSEE, West Virginia University, Morgantown, WV {ksmani@csee.wvu.edu} 1 Problems 1. Solve the following recurrence using substitution:
More informationCOSE312: Compilers. Lecture 17 Intermediate Representation (2)
COSE312: Compilers Lecture 17 Intermediate Representation (2) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 17 May 31, 2017 1 / 19 Common Intermediate Representations Three-address code
More informationCSE 150. Assignment 6 Summer Maximum likelihood estimation. Out: Thu Jul 14 Due: Tue Jul 19
SE 150. Assignment 6 Summer 2016 Out: Thu Jul 14 ue: Tue Jul 19 6.1 Maximum likelihood estimation A (a) omplete data onsider a complete data set of i.i.d. examples {a t, b t, c t, d t } T t=1 drawn from
More informationData-Flow Analysis. Compiler Design CSE 504. Preliminaries
Data-Flow Analysis Compiler Design CSE 504 1 Preliminaries 2 Live Variables 3 Data Flow Equations 4 Other Analyses Last modifled: Thu May 02 2013 at 09:01:11 EDT Version: 1.3 15:28:44 2015/01/25 Compiled
More informationComputing Static Single Assignment (SSA) Form
Computing Static Single Assignment (SSA) Form Overview What is SSA? Advantages of SSA over use-def chains Flavors of SSA Dominance frontiers revisited Inserting φ-nodes Renaming the variables Translating
More informationSolving Linear Systems Using Gaussian Elimination
Solving Linear Systems Using Gaussian Elimination DEFINITION: A linear equation in the variables x 1,..., x n is an equation that can be written in the form a 1 x 1 +...+a n x n = b, where a 1,...,a n
More informationLecture 10: Data Flow Analysis II
CS 515 Programming Language and Compilers I Lecture 10: Data Flow Analysis II (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang
More informationCentral Algorithmic Techniques. Iterative Algorithms
Central Algorithmic Techniques Iterative Algorithms Code Representation of an Algorithm class InsertionSortAlgorithm extends SortAlgorithm { void sort(int a[]) throws Exception { for (int i = 1; i < a.length;
More informationProblem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26
Binary Search Introduction Problem Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Strategy 1: Random Search Randomly select a page until the page containing
More informationDataflow Analysis. Dragon book, Chapter 9, Section 9.2, 9.3, 9.4
Dataflow Analysis Dragon book, Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub-area of static program analysis Used in the compiler back end for optimizations of three-address
More informationLecture 6 September 21, 2016
ICS 643: Advanced Parallel Algorithms Fall 2016 Lecture 6 September 21, 2016 Prof. Nodari Sitchinava Scribe: Tiffany Eulalio 1 Overview In the last lecture, we wrote a non-recursive summation program and
More informationMonotone Data Flow Analysis Framework
Monotone Data Flow Analysis Framework Definition. A relation R on a set S is (a) reflexive iff ( x S)[xRx], (b) antisymmetric iff [xry yrx x=y] (c) transitive iff ( x,y,z S) [xry yrz xrz] Definition. A
More informationLecture 2: Divide and conquer and Dynamic programming
Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in
More information10-810: Advanced Algorithms and Models for Computational Biology. microrna and Whole Genome Comparison
10-810: Advanced Algorithms and Models for Computational Biology microrna and Whole Genome Comparison Central Dogma: 90s Transcription factors DNA transcription mrna translation Proteins Central Dogma:
More informationTop Down Design. Gunnar Gotshalks 03-1
Top Down Design 03-1 Top Down Description Top down is also known as step wise refinement and functional decomposition Given an operation, there are only the following three choices for refinement» Sequence
More information: Compiler Design. 9.5 Live variables 9.6 Available expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland
252-210: Compiler Design 9.5 Live variables 9.6 Available expressions Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Outline Warp up reaching definifons Live variables Available expressions
More informationContents. Counting Methods and Induction
Contents Counting Methods and Induction Lesson 1 Counting Strategies Investigations 1 Careful Counting... 555 Order and Repetition I... 56 3 Order and Repetition II... 569 On Your Own... 573 Lesson Counting
More informationIntra-procedural Data Flow Analysis Backwards analyses
Live variables Dead code elimination Very Busy Expressions Code hoisting Bitvector frameworks Monotone frameworks Intra-procedural Data Flow Analysis Backwards analyses Hanne Riis Nielson and Flemming
More informationThe Meet-Over-All-Paths Solution to Data-Flow Problems
The Meet-Over-All-Paths Solution to Data-Flow Problems Consider a monotone dataflow framework (L,,F). Assume that the functions f B F represent the effect of a basic block on the sets conatining data for
More informationCMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis
CMSC 631 Program Analysis and Understanding Spring 2013 Data Flow Analysis Data Flow Analysis A framework for proving facts about programs Reasons about lots of little facts Little or no interaction between
More informationFormal Methods in Software Engineering
Formal Methods in Software Engineering An Introduction to Model-Based Analyis and Testing Vesal Vojdani Department of Computer Science University of Tartu Fall 2014 Vesal Vojdani (University of Tartu)
More informationFinal. Introduction to Artificial Intelligence. CS 188 Spring You have approximately 2 hours and 50 minutes.
CS 188 Spring 2014 Introduction to Artificial Intelligence Final You have approximately 2 hours and 50 minutes. The exam is closed book, closed notes except your two-page crib sheet. Mark your answers
More informationSequential programs. Uri Abraham. March 9, 2014
Sequential programs Uri Abraham March 9, 2014 Abstract In this lecture we deal with executions by a single processor, and explain some basic notions which are important for concurrent systems as well.
More informationQ520: Answers to the Homework on Hopfield Networks. 1. For each of the following, answer true or false with an explanation:
Q50: Answers to the Homework on Hopfield Networks 1. For each of the following, answer true or false with an explanation: a. Fix a Hopfield net. If o and o are neighboring observation patterns then Φ(
More informationWe define a dataflow framework. A dataflow framework consists of:
So far been talking about various dataflow problems (e.g. reaching definitions, live variable analysis) in very informal terms. Now we will discuss a more fundamental approach to handle many of the dataflow
More information1.10 Matrix Representation of Graphs
42 Basic Concepts of Graphs 1.10 Matrix Representation of Graphs Definitions: In this section, we introduce two kinds of matrix representations of a graph, that is, the adjacency matrix and incidence matrix
More informationSubcubic Equivalence of Triangle Detection and Matrix Multiplication
Subcubic Equivalence of Triangle Detection and Matrix Multiplication Bahar Qarabaqi and Maziar Gomrokchi April 29, 2011 1 Introduction An algorithm on n n matrix with the entries in [ M, M] has a truly
More informationCSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions
CSE 502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions 1. Consider the following algorithm: for i := 1 to α n log e n do Pick a random j [1, n]; If a[j] = a[j + 1] or a[j] = a[j 1] then output:
More informationPrinciples of Program Analysis: A Sampler of Approaches
Principles of Program Analysis: A Sampler of Approaches Transparencies based on Chapter 1 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis Springer Verlag
More informationMostly Review. Phy 123L
Name: Significant Digits, Unit Conversions, Graphing and Uncertainties in Measurements =========================================================== Choose the best answer. (30 pts total) 1. Do the following
More informationCSCE 750, Spring 2001 Notes 1 Page 1 An outline of the book 1. Analyzing algorithms 2. Data abstraction 3. Recursion and induction 4. Sorting 5. Selec
CSCE 750, Spring 2001 Notes 1 Page 1 An outline of the book 1. Analyzing algorithms 2. Data abstraction 3. Recursion and induction 4. Sorting 5. Selection and adversary arguments 6. Dynamic sets and searching
More informationOutline. 1 Introduction. 3 Quicksort. 4 Analysis. 5 References. Idea. 1 Choose an element x and reorder the array as follows:
Outline Computer Science 331 Quicksort Mike Jacobson Department of Computer Science University of Calgary Lecture #28 1 Introduction 2 Randomized 3 Quicksort Deterministic Quicksort Randomized Quicksort
More informationStatic Analysis of Programs: A Heap-Centric View
Static Analysis of Programs: A Heap-Centric View (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 5 April 2008 Part 1 Introduction ETAPS
More informationSFG and Mason s Rule : A revision
SFG and Mason s Rule : A revision Andersen Ang 2016-Nov-29 SFG and Mason s Rule Vu Pham Review SFG: Signal-Flow Graph SFG is a directed graph SFG is used to model signal flow in a system SFG can be used
More informationMIDTERM: CS 6375 INSTRUCTOR: VIBHAV GOGATE October,
MIDTERM: CS 6375 INSTRUCTOR: VIBHAV GOGATE October, 23 2013 The exam is closed book. You are allowed a one-page cheat sheet. Answer the questions in the spaces provided on the question sheets. If you run
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17
601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 12.1 Introduction Today we re going to do a couple more examples of dynamic programming. While
More informationCS Algorithms and Complexity
CS 50 - Algorithms and Complexity Linear Programming, the Simplex Method, and Hard Problems Sean Anderson 2/15/18 Portland State University Table of contents 1. The Simplex Method 2. The Graph Problem
More informationStepwise Refinement! Top Down Design!
Stepwise Refinement Top Down Design 11-1 On Top Down Design Useful in creating a function or algorithm when the input and output data structures correspond» If the input and output data structures do not
More informationSAMPLE EXAMINATION PAPER FORM 3
THE G C SCHOOL OF CAREERS MATHEMATICS DEPARTMENT SCHOOL YEAR 2017-2018 SAMPLE EXAMINATION PAPER FORM 3 Name: INFORMATION TO CANDIDATES Full marks may be obtained for answers to ALL questions. This paper
More informationInference and Representation
Inference and Representation David Sontag New York University Lecture 5, Sept. 30, 2014 David Sontag (NYU) Inference and Representation Lecture 5, Sept. 30, 2014 1 / 16 Today s lecture 1 Running-time of
More informationALMOST SURE CONVERGENCE OF RANDOM GOSSIP ALGORITHMS
ALMOST SURE CONVERGENCE OF RANDOM GOSSIP ALGORITHMS Giorgio Picci with T. Taylor, ASU Tempe AZ. Wofgang Runggaldier s Birthday, Brixen July 2007 1 CONSENSUS FOR RANDOM GOSSIP ALGORITHMS Consider a finite
More informationConstruction of Static Single-Assignment Form
COMP 506 Rice University Spring 2018 Construction of Static Single-Assignment Form Part II source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all
More informationBDD Based Upon Shannon Expansion
Boolean Function Manipulation OBDD and more BDD Based Upon Shannon Expansion Notations f(x, x 2,, x n ) - n-input function, x i = or f xi=b (x,, x n ) = f(x,,x i-,b,x i+,,x n ), b= or Shannon Expansion
More informationAlgorithms. Quicksort. Slide credit: David Luebke (Virginia)
1 Algorithms Quicksort Slide credit: David Luebke (Virginia) Sorting revisited We have seen algorithms for sorting: INSERTION-SORT, MERGESORT More generally: given a sequence of items Each item has a characteristic
More informationAnalysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.
Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci
More information5. Is it OK to change the spacing of the tick marks on your axes as you go across the page? a. Yes b. No - that screws up the analysis of the data.
Name: Significant Digits, Unit Conversions, Graphing and Uncertainties in Measurements =========================================================== Choose the best answer. (30 pts total) Significant Digits,
More informationMIT Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology
MIT 6.035 Foundations of Dataflow Analysis Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Dataflow Analysis Compile-Time Reasoning About Run-Time Values of Variables
More information1. Solve the inequality 2 (3 + x) < 4x + 4 < 8x. Give the result in set notation and graph it.
Student ID: 21942320 Exam: 050291RR - Systems of Equations; Inequalities When you have completed your exam and reviewed your answers, click Submit Exam. Answers will not be recorded until you hit Submit
More informationAmortized Complexity Main Idea
omp2711 S1 2006 Amortized Complexity Example 1 Amortized Complexity Main Idea Worst case analysis of run time complexity is often too pessimistic. Average case analysis may be difficult because (i) it
More informationNP-Hardness reductions
NP-Hardness reductions Definition: P is the class of problems that can be solved in polynomial time, that is n c for a constant c Roughly, if a problem is in P then it's easy, and if it's not in P then
More informationARE YOU READY FOR CALCULUS?
ARE YOU READY FOR CALCULUS? Congratulations! You made it to Calculus AB! Instructions 1. Please complete the packet (see below), which will be due the day of registration. This packet will help you review
More informationValue Range Propagation
Value Range Propagation LLVM Adam Wiggs Patryk Zadarnowski {awiggs,patrykz}@cse.unsw.edu.au 17 June 2003 University of New South Wales Sydney MOTIVATION The Problem: X Layout of basic blocks LLVM is bra-dead.
More informationDonoghue, Golowich, Holstein Chapter 4, 6
1 Week 7: Non linear sigma models and pion lagrangians Reading material from the books Burgess-Moore, Chapter 9.3 Donoghue, Golowich, Holstein Chapter 4, 6 Weinberg, Chap. 19 1 Goldstone boson lagrangians
More informationNATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours
NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: 2017 2018 Time Allowed 2 Hours INSTRUCTIONS TO STUDENTS 1. This assessment consists of Eight (8) questions and comprises
More information3. What is the decimal place of the least significant figure (LSF) in the number 0.152? a. tenths place b. hundredths place c.
Name: Significant Digits, Unit Conversions, Graphing and Uncertainties in Measurements =========================================================== Choose the best answer. (30 pts total) Significant Digits,
More informationSystems of Linear Equations
4 Systems of Linear Equations Copyright 2014, 2010, 2006 Pearson Education, Inc. Section 4.1, Slide 1 1-1 4.1 Systems of Linear Equations in Two Variables R.1 Fractions Objectives 1. Decide whether an
More informationScalar Optimisation Part 1
calar Optimisation Part 1 Michael O Boyle January, 2014 1 Course tructure L1 Introduction and Recap 4/5 lectures on classical optimisation 2 lectures on scalar optimisation Today example optimisations
More informationAlgorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)
Algorithms and Data Structures 016 Week 5 solutions (Tues 9th - Fri 1th February) 1. Draw the decision tree (under the assumption of all-distinct inputs) Quicksort for n = 3. answer: (of course you should
More informationCreated by T. Madas. Candidates may use any calculator allowed by the regulations of this examination.
IYGB GCE Mathematics MP1 Advanced Level Practice Paper P Difficulty Rating: 3.9900/1.3930 Time: 2 hours Candidates may use any calculator allowed by the regulations of this eamination. Information for
More informationModule 1: Analyzing the Efficiency of Algorithms
Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?
More informationLab 6: Linear Algebra
6.1 Introduction Lab 6: Linear Algebra This lab is aimed at demonstrating Python s ability to solve linear algebra problems. At the end of the assignment, you should be able to write code that sets up
More informationData selection. Lower complexity bound for sorting
Data selection. Lower complexity bound for sorting Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 12 1 Data selection: Quickselect 2 Lower complexity bound for sorting 3 The
More informationLecture 38 Insulated Boundary Conditions
Lecture 38 Insulated Boundary Conditions Insulation In many of the previous sections we have considered fixed boundary conditions, i.e. u(0) = a, u(l) = b. We implemented these simply by assigning u j
More informationAvon High School Name AP Calculus AB Summer Review Packet Score Period
Avon High School Name AP Calculus AB Summer Review Packet Score Period f 4, find:.) If a.) f 4 f 4 b.) Topic A: Functions f c.) f h f h 4 V r r a.) V 4.) If, find: b.) V r V r c.) V r V r.) If f and g
More informationGCSE (9-1) Paper 2H (Calculator)
GCSE (9-1) Paper H (Calculator) Practice set A 017 crashmaths Limited CM GCSE Practice Papers / Set A / Paper H (V1 FINAL) 1 (a) (1, 0) 1 B1 : cao (b) rotation 3 B1 : correct orientation of the shape (m
More informationCOMP 515: Advanced Compilation for Vector and Parallel Processors. Vivek Sarkar Department of Computer Science Rice University
COMP 515: Advanced Compilation for Vector and Parallel Processors Vivek Sarkar Department of Computer Science Rice University vsarkar@rice.edu COMP 515 Lecture 3 13 January 2009 Acknowledgments Slides
More informationProbabilistic Model Checking and [Program] Analysis (CO469)
Probabilistic Model Checking and [Program] Analysis (CO469) Program Analysis Herbert Wiklicky herbert@doc.ic.ac.uk Spring 208 / 64 Overview Topics we will cover in this part will include:. Language WHILE
More informationThe Data-Dependence graph of Adjoint Codes
The Data-Dependence graph of Adjoint Codes Laurent Hascoët INRIA Sophia-Antipolis November 19th, 2012 (INRIA Sophia-Antipolis) Data-Deps of Adjoints 19/11/2012 1 / 14 Data-Dependence graph of this talk
More informationLoop Parallelization Techniques and dependence analysis
Loop Parallelization Techniques and dependence analysis Data-Dependence Analysis Dependence-Removing Techniques Parallelizing Transformations Performance-enchancing Techniques 1 When can we run code in
More informationCS156: The Calculus of Computation Zohar Manna Autumn 2008
Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)
More informationDataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4
Dataflow Analysis Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub area of static program analysis Used in the compiler back end for optimizations of three address code and
More informationCSE 202 Homework 4 Matthias Springer, A
CSE 202 Homework 4 Matthias Springer, A99500782 1 Problem 2 Basic Idea PERFECT ASSEMBLY N P: a permutation P of s i S is a certificate that can be checked in polynomial time by ensuring that P = S, and
More informationLearning Goals of CS245 Logic and Computation
Learning Goals of CS245 Logic and Computation Alice Gao April 27, 2018 Contents 1 Propositional Logic 2 2 Predicate Logic 4 3 Program Verification 6 4 Undecidability 7 1 1 Propositional Logic Introduction
More informationExam in Discrete Mathematics
Exam in Discrete Mathematics First Year at The TEK-NAT Faculty June 10th, 2016, 9.00-13.00 This exam consists of 11 numbered pages with 16 problems. All the problems are multiple choice problems. The answers
More informationCMPUT651: Differential Privacy
CMPUT65: Differential Privacy Homework assignment # 2 Due date: Apr. 3rd, 208 Discussion and the exchange of ideas are essential to doing academic work. For assignments in this course, you are encouraged
More informationStudent ID: Exam: RR - SYSTEMS OF EQUATIONS; INEQUALITIES. 1. Graph the inequality y 3.
Student ID: 21745663 Exam: 050353RR - SYSTEMS OF EQUATIONS; INEQUALITIES When you have completed your exam and reviewed your answers, click Submit Exam. Answers will not be recorded until you hit Submit
More information5. Density evolution. Density evolution 5-1
5. Density evolution Density evolution 5-1 Probabilistic analysis of message passing algorithms variable nodes factor nodes x1 a x i x2 a(x i ; x j ; x k ) x3 b x4 consider factor graph model G = (V ;
More information