: Compiler Design. 9.5 Live variables 9.6 Available expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland

Size: px
Start display at page:

Download ": Compiler Design. 9.5 Live variables 9.6 Available expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland"

Transcription

1 : Compiler Design 9.5 Live variables 9.6 Available expressions Thomas R. Gross Computer Science Department ETH Zurich, Switzerland

2 Outline Warp up reaching definifons Live variables Available expressions 21

3 Food for thought void foo(int x) { } int a, b, c; a = x + 1; if ( ) { b = x; } else { } c = b + 1; return c; // no a, b d1: a = x + 1 if (Tcond) d2: b = x IN = {d1,d2} d3: c = b + 1 return c 22

4 Food for thought void foo(int x) { } int a, b, c; a = x + 1; if ( ) { b = x; } else { } c = b + 1; return c; // no a, b d1: a = x + 1 if (Tcond) d2: b = x IN = {d1,d2} d3: c = x + 1 return c 23

5 Program is broken As far as we can tell, d3 may read an undefined value of b Maybe not cannot decide in general Don t know anything about Tcond Our model is: if there is an edge in the CFG, control may be transferred A consequence 24

6 Food for thought d1: a = x + 1 if (Tcond1) // no a, b d2: b = x d3: a = y + 1 if (Tcond?) d5: c = a + 1 return c IN = {d3,d2} // no a, b d4: c = b

7 Program is broken d4 may read an undefined value of b Or if Tcond? == TCond1 it does not read an undefined value But we do not know there is a path along which b is undefined Could we use reaching definifons to idenffy such trouble spots Back to the use of flow analysis for program checking 26

8 UniniFalized variables Reaching definifons: set of definifons that reach start of a basic block Idea: insert fake definifons into the ENTRY node One for each variable fake means there is no correspondence in the source program IdenZfy by tag, number,.. (here number > 100) Start iterazon with OUT(ENTRY) = set of fake definizons If a fake definifon d that sets desfnafon dest reaches a block B, and there is a use of dest in B prior to any definifon of dest in B, then dest is potenfally uninifalized Compiler can (in general) only issue warning, cannot be sure variable is uninizalized 27

9 UniniFalized variables d100: a = d101: b = d102: c = ENTRY IN: {d1, d101, d102} IN: {d3,d2, d101, d102} IN: {d100, d101, d102} // no a, b IN: {d1,d2, d101, d102} d1: a = x + 1 if (Tcond1) d3: a = y + 1 if (Tcond2) d2: b = x IN: {d1,d101,d102} IN: {d3,d2,d101, d102} // no a, b d4: c = b + 1 IN: {d3,d2,d4,d101, d102} x or y are fields or parameters so we do not need a fake definizon d5: c = a + 1 return c EXIT 28

10 UniniFalized variables d100: a = d101: b = ENTRY // no a or b if (Tcond1) d1: a = x + 1 d2: b = x + 2 IN: {d1,d2, d101, d100} x or y are fields or parameters so we do not need a fake definizon d3: x = a + 1 d4: b = y + 1 d5: y = b + 1

11 UniniFalized variables ENTRY d100: a = // no a or b if (Tcond1) d1: a = x + 1 d2: a = x + 2 IN: {d1,d2} d3: a = a + 1 return a x is a field or parameter so we do not need a fake definizon

12 Program analysis Compiler needs informafon Specific problem Devise flow analysis to compute informafon Let compiler use informafon to deal with specific problem 31

13 9.5 Live variables FoundaFons for several opfmizafons If a variable is not live, it s dead. No need to store value in dead variables Outline Data flow problem Transfer funczon Examples 32

14 Wishlist Given a statement S dest = operand1 operand2 Compiler would like to know at point P if there is a further use of dest I.e., there is a statement S that uses dest and there is a path from P to P before_s One interesfng point is P aaer_s or P aaer_b (with B the basic block of S) But every point could be interesfng Like to know if operandx is used again in another statement 33

15 Data flow problem Similar to reaching definifons but not interested what has happened prior to reaching P but what happens aaer P Consider all paths that start at P and go to EXIT A variable V is live at point P if there is a path from P to EXIT that contains a statement S that uses V, and there is no definifon of V on this path between P and S. Path can start anywhere Ojen we care about paths that start ajer a definizon of V A single path with a use is enough for V to be live at P A variable that is not live is called dead. Recall that we assume all statements have clearly idenffiable operands and desfnafons 34

16 Live variables Live variable analysis determines for all points P the set of variables that are live. We care primarily about live variables at the end of a basic block. Handling a basic block is easy if we know what s live at the end There are many opfmizafons that are based on live variable analysis If a variable is dead at P then it s not necessary to store the variable If a register is needed and one of the registers contains a dead variable, this register can be used right away no need to save the current content 35

17 No need to store value computed by S2 in variable W If expr has no side effect stmt can be removed V is local to basic block B If Y is in a register this register can be released aaer S4 S1: V = S2: W = expr S3: = X V S4: = Y 1 S5: = Z Live = { X, Z} B 36

18 Transfer funcfon d: = var B var is live at the start of basic block B if there is no stmt in B prior to d that defines var 37

19 Transfer funcfon d: = var d : var = var is live at the start of basic block B if there is no stmt in B prior to d that defines var 38

20 Transfer funcfon d : var = d: = var var is not live at the start of basic block B as there is a stmt in B prior to d that defines var DefiniZon d 39

21 Transfer funcfon d: = var Define for basic block B def B = { var var is defined in B prior to any use of var in B } use B = { var var is used in B prior to any definizon of var in B } 40

22 Transfer funcfon d: = var Define for basic block B def B = { var var is defined in B and there is no use of var in B } use B = { var var is used in B and there is no definizon of var in B } DefiniFons and uses of a variable: must be conservafve In def only if we are sure the variable is set In use if there is a chance that the value is used 41

23 Transfer funcfon NoFce that we may be interested in the set of live variables at the start of a basic block Determined by statements in basic block and statements in subsequent basic blocks Eventually we also figure out what s live at the end of a basic block Set of live variables at the end of a basic block Determined by statements in subsequent basic blocks Another term: live == downward exposed 42

24 Transfer funcfon IN(B) = {v 1, v 2,, v n } d: = var For a basic block B we define IN(B) = { var var live at P before_b } OUT(B) = { var var live at P ajer_b } OUT(B) = {v 1, v 2,, v m } Variable v IN(B) v is used in B prior to any definizon, i.e. v use B v OUT(B) and v not set by statements in B, i.e. v def B IN(B) = use B (OUT(B) def B ) 43

25 Transfer funcfon B2 B3... B1 Given IN(B1) What should be OUT(B2) and OUT(B3)? OUT(B2) = IN(B1), OUT(B3) = IN(B1) 44

26 Transfer funcfon... B1 B2 B3 Given IN(B2) and IN(B3) What should be OUT(B1)? A variable var is live at a point P if there is a path from P to EXIT such that var is used along that path prior to any definizon Must consider all paths starzng at P 45

27 Transfer funcfon... B1 B2 B3 Given IN(Bi) OUT(B) = Bi, Bi is successor of B in CFG IN(Bi) 46

28 Finding IN and OUT def B and use B capture what happens inside a basic block. 47

29 Example ENTRY d1: i = m 1 d2: j = n d3: a = d4: i = i + 1 d5: j = j - 1 d6: a = d7: i = From Aho et al Compilers, p 604 EXIT 48

30 Example def = {i, j, a} use = {m, n } ENTRY d1: i = m 1 d2: j = n d3: a = def = {} use = {i, j} d4: i = i + 1 d5: j = j - 1 def = {a} use = d6: a = def = {i} use = d7: i = From Aho et al Compilers, p 604 EXIT 49

31 Finding IN(B) and OUT(B) N basic blocks, 2 N sets IN / OUT System with 2 N unknowns Solve by iterazng unzl a fixed point is found How to start iterafon? Safe assumpzon IN[EXIT] = Nothing is live at the end 50

32 Finding live variables IN[EXIT] = IniZalize IN[B] = for B EXIT while (changes to any IN(B)) { for (each basic block B EXIT) { OUT(B) = Bi, Bi is successor of B in CFG IN(Bi) IN(B) = use B (OUT(B) def B ) } } 51

33 Example def = {i, j, a} use = {m, n } ENTRY d1: i = m 1 d2: j = n d3: a = def = {} use = {i, j} d4: i = i + 1 d5: j = j - 1 def = {a} use = d6: a = def = {i} use = d7: i = From Aho et al Compilers, p 604 EXIT 52

34 Example def = {i, j, a} use = { m, n } ENTRY d1: i = m 1 d2: j = n d3: a = IN(B1) {m,n} OUT(B1) {i,j} def = {} use = {i, j} d4: i = i + 1 d5: j = j - 1 IN(B2) OUT(B2) {i,j} {j} d6: a = def = {a} use = def = {i} use = IN(B3) {j} OUT(B3) {j} d7: i = IN(B4) OUT(B4) {j} {i,j} From Aho et al Compilers, p 604 EXIT IN(EXIT) 53

35 Comments The set use B includes also uses in statements that are not assignment statements Expression in if-then statements Expressions in while loops Actuals in method calls The order of visifng the basic blocks (in main loop) determines how fast the fixed point is found But not the final result There may be other solufons that are also correct 54

36 Summary Reaching definifons and live variables require a similar approach Compute two sets for each basic block B SoluZon = OUT(B) / IN(B) Context = IN(B) / OUT(B) Two sets to capture local effects local_cut = def B (but with different meaning: sets of definizons/sets of variables) local_new = gen B / use B Init SoluZon(ENTRY) / SoluZon(EXIT) i.e. OUT(ENTRY) / IN(EXIT) Init remaining SoluZon sets Iterate over basic blocks B Context(B) = Bi, Bi is predecessor/successor of B in CFG SoluZon(Bi) SoluZon(B) = local_new B (Context(B) local_cut B ) 55

37 Def-use and use-def chains Store informafon about reaching definifons and live variables as lists For each use of a variable include in the list all definizons that reach this use (use-def chain) For each point P (definizon of a variable) include in the list all uses of this variable DU chains or UD chains for short Can be obtained directly from solufon to global data flow problem 56

38 57

39 DU chain def = {i, j, a} use = { m, n } ENTRY d1: i = m 1 d2: j = n d3: a = IN(B1) {m,n} OUT(B1) {i,j} def = {} use = {i, j} d4: i = i + 1 d5: j = j - 1 IN(B2) OUT(B2) {i,j} {j} d6: a = def = {a} use = def = {i} use = IN(B3) {j} OUT(B3) {j} d7: i = IN(B4) OUT(B4) {j} {i,j} From Aho et al Compilers, p 604 EXIT IN(EXIT) 58

40 ENTRY UD/DU chains Show the DU and UD chains r = 3 s = t t = u r = r + 1 v = r * s s = 0 s = s + 1 u = r + s w = u + 2 EXIT 59

41 60

42 Flow of informafon Reaching definifon: j ENTRY d1: i = m 1 d2: j = n d3: a = d4: = i + 1 d5: j = j - 1 d6: a = i + 1 d7: i = EXIT 61

43 62

44 Flow of informafon Live variable: i ENTRY d1: i = m 1 d2: j = n d3: a = d4: = i + 1 d5: j = j - 1 d6: a = i + 1 d7: i = EXIT 63

45 Flow of informafon Live variable: j ENTRY d1: i = m 1 d2: j = n d3: a = d4: = i + 1 d5: j = j - 1 d6: a = i + 1 d7: i = EXIT 64

46 ImplicaFons Should try to propagate informafon in the direcfon of the flow For speed of conversion, not for correctness Reaching definifons: forward problem InformaZon flows in the direczon of the CFG, from ENTRY to EXIT Live variables: backward problem InformaZon flows from EXIT to ENTRY 65

47 ImplementaFon ENTRY d1: i = m 1 d2: j = n d3: a = d4: i = i + 1 d5: j = j - 1 d6: a = d7: i = Flow graph as used when EXIT compufng reaching definifons 66

48 ImplementaFon EXIT d1: i = m 1 d2: j = n d3: a = d4: i = i + 1 d5: j = j - 1 d6: a = d7: i = Flip flow graph when compufng ENTRY live variables 67

49 Program analysis Compiler needs informafon Specific problem Devise flow analysis to compute informafon Can we think of other kinds of informafon that might be useful to the compiler? 68

50 9.6 Available expressions x = a + b if (Tcond1) B1 // no change to a,b // no change to a,b y = a + b Expression a+b evaluated twice: in B1 and B4 B4 Q1: Can we determine that a+b in B1 yields the idenfcal result as a+b in B4? Q2: Does it make sense to reuse the value from B1? Postpone the answer to last queszon Q2 69

51 Available expressions An expression a+b is available at a point P if a+b is evaluated on every path from ENTRY to P and there is no definifon of a or b on this path aaer a+b was evaluated Interested in set of expressions available at the start of a basic block B Set depends on paths that lead to P before_b Assume that a+b has no side effects Reading a memory locazon may have side effects too! Not a problem for JavaLi or Java 70

52 Available expressions e1: x = a + b if (Tcond) B1 B2?? Is a+b computed in e1 available for e2? Available at P Depends on B2 P e2: y = a + b B3 71

53 Available expressions e1: x = a + b if (Tcond) B1 B2 a = Is a+b computed in e1 available for e2? No a may have at P a value that differs from the value at e1. P e2: y = a + b B3 72

54 Available expressions e1: x = a + b if (Tcond) B1 B2 a = e3: z = a + b Is a+b available for e2? Yes either computed by e1 or by e3 P e2: y = a + b B3 73

55 Transfer funcfon e: = a + b B a+b is available at the end of basic block B if there is no stmt in B that follows e and that defines a or b Must be conservazve If a statement in the shaded region may modify a (or b) then a+b is not available at the end of B 74

Compiler Design Spring 2017

Compiler 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 information

Compiler Design Spring 2017

Compiler 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 information

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation

Dataflow 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 information

Lecture 5 Introduction to Data Flow Analysis

Lecture 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 information

: Compiler Design

: Compiler Design 252-210: Compiler Design 9.2 Points and paths 9.3 Transfer func6ons Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Outline Points Paths Transfer funceons 2 Terminology Local {analysis

More information

Dataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) {

Dataflow 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 information

Topic-I-C Dataflow Analysis

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 information

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis

CMSC 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 information

Lecture 4 Introduc-on to Data Flow Analysis

Lecture 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 information

CSC D70: Compiler Optimization Dataflow-2 and Loops

CSC 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 information

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries

Data-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 information

Generalizing Data-flow Analysis

Generalizing 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 information

CSC D70: Compiler Optimization Static Single Assignment (SSA)

CSC D70: Compiler Optimization Static Single Assignment (SSA) CSC D70: Compiler Optimization Static Single Assignment (SSA) Prof. Gennady Pekhimenko University of Toronto Winter 08 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip

More information

Data flow analysis. DataFlow analysis

Data 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 information

Compiler Design. Data Flow Analysis. Hwansoo Han

Compiler 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 information

Dataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4

Dataflow 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 information

What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed

What 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 information

Dataflow 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 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 information

(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;

(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; (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

More information

Topics on Compilers

Topics 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 information

3/11/18. Final Code Generation and Code Optimization

3/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 information

Data Flow Analysis (I)

Data 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 information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Saturday, April 23, Dependence Analysis

Saturday, April 23, Dependence Analysis Dependence Analysis Motivating question Can the loops on the right be run in parallel? i.e., can different processors run different iterations in parallel? What needs to be true for a loop to be parallelizable?

More information

Math 471 (Numerical methods) Chapter 3 (second half). System of equations

Math 471 (Numerical methods) Chapter 3 (second half). System of equations Math 47 (Numerical methods) Chapter 3 (second half). System of equations Overlap 3.5 3.8 of Bradie 3.5 LU factorization w/o pivoting. Motivation: ( ) A I Gaussian Elimination (U L ) where U is upper triangular

More information

Dataflow analysis. Theory and Applications. cs6463 1

Dataflow 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 information

We define a dataflow framework. A dataflow framework consists of:

We 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 information

Chapter 1 Review of Equations and Inequalities

Chapter 1 Review of Equations and Inequalities Chapter 1 Review of Equations and Inequalities Part I Review of Basic Equations Recall that an equation is an expression with an equal sign in the middle. Also recall that, if a question asks you to solve

More information

Compiling Techniques

Compiling Techniques Lecture 11: Introduction to 13 November 2015 Table of contents 1 Introduction Overview The Backend The Big Picture 2 Code Shape Overview Introduction Overview The Backend The Big Picture Source code FrontEnd

More information

: Advanced Compiler Design Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming

: Advanced Compiler Design Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming 263-2810: Advanced Compiler Design 3.3.2 Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming Thomas R. Gross Computer Science Department ETH Zurich, Switzerland

More information

Markov Chain Monte Carlo The Metropolis-Hastings Algorithm

Markov Chain Monte Carlo The Metropolis-Hastings Algorithm Markov Chain Monte Carlo The Metropolis-Hastings Algorithm Anthony Trubiano April 11th, 2018 1 Introduction Markov Chain Monte Carlo (MCMC) methods are a class of algorithms for sampling from a probability

More information

CSE 311: Foundations of Computing. Lecture 27: Undecidability

CSE 311: Foundations of Computing. Lecture 27: Undecidability CSE 311: Foundations of Computing Lecture 27: Undecidability Last time: Countable sets A set is countable iff we can order the elements of as = {,,, Countable sets: N-the natural numbers Z - the integers

More information

Q520: Answers to the Homework on Hopfield Networks. 1. For each of the following, answer true or false with an explanation:

Q520: 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 information

Lecture 10: Data Flow Analysis II

Lecture 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 information

CSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1

CSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1 CSE P 501 Compilers Value Numbering & Op;miza;ons Hal Perkins Winter 2016 UW CSE P 501 Winter 2016 S-1 Agenda Op;miza;on (Review) Goals Scope: local, superlocal, regional, global (intraprocedural), interprocedural

More information

Getting Started with Communications Engineering

Getting Started with Communications Engineering 1 Linear algebra is the algebra of linear equations: the term linear being used in the same sense as in linear functions, such as: which is the equation of a straight line. y ax c (0.1) Of course, if we

More information

Alpha-Beta Pruning: Algorithm and Analysis

Alpha-Beta Pruning: Algorithm and Analysis Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for solving

More information

Clojure Concurrency Constructs, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014

Clojure Concurrency Constructs, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014 Clojure Concurrency Constructs, Part Two CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014 1 Goals Cover the material presented in Chapter 4, of our concurrency textbook In particular,

More information

Alpha-Beta Pruning: Algorithm and Analysis

Alpha-Beta Pruning: Algorithm and Analysis Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person

More information

Static Analysis of Programs: A Heap-Centric View

Static 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 information

Lecture 27: Theory of Computation. Marvin Zhang 08/08/2016

Lecture 27: Theory of Computation. Marvin Zhang 08/08/2016 Lecture 27: Theory of Computation Marvin Zhang 08/08/2016 Announcements Roadmap Introduction Functions Data Mutability Objects This week (Applications), the goals are: To go beyond CS 61A and see examples

More information

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations Lab 2 Worksheet Problems Problem : Geometry and Linear Equations Linear algebra is, first and foremost, the study of systems of linear equations. You are going to encounter linear systems frequently in

More information

Model Checking & Program Analysis

Model Checking & Program Analysis Model Checking & Program Analysis Markus Müller-Olm Dortmund University Overview Introduction Model Checking Flow Analysis Some Links between MC and FA Conclusion Apology for not giving proper credit to

More information

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018 CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts

More information

Lesson 7: Classification of Solutions

Lesson 7: Classification of Solutions Student Outcomes Students know the conditions for which a linear equation will have a unique solution, no solution, or infinitely many solutions. Lesson Notes Part of the discussion on the second page

More information

Worst-Case Execution Time Analysis. LS 12, TU Dortmund

Worst-Case Execution Time Analysis. LS 12, TU Dortmund Worst-Case Execution Time Analysis Prof. Dr. Jian-Jia Chen LS 12, TU Dortmund 02, 03 May 2016 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 1 / 53 Most Essential Assumptions for Real-Time Systems Upper

More information

MA 1128: Lecture 08 03/02/2018. Linear Equations from Graphs And Linear Inequalities

MA 1128: Lecture 08 03/02/2018. Linear Equations from Graphs And Linear Inequalities MA 1128: Lecture 08 03/02/2018 Linear Equations from Graphs And Linear Inequalities Linear Equations from Graphs Given a line, we would like to be able to come up with an equation for it. I ll go over

More information

Adventures in Dataflow Analysis

Adventures 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 information

Alpha-Beta Pruning: Algorithm and Analysis

Alpha-Beta Pruning: Algorithm and Analysis Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person

More information

DFA of non-distributive properties

DFA of non-distributive properties DFA of non-distributive properties The general pattern of Dataflow Analysis GA (p)= i if p E { GA (q) q F } otherwise GA (p)= f p ( GA (p) ) where : E is the set of initial/final points of the control-flow

More information

DIFFERENTIAL EQUATIONS

DIFFERENTIAL EQUATIONS DIFFERENTIAL EQUATIONS Basic Concepts Paul Dawkins Table of Contents Preface... Basic Concepts... 1 Introduction... 1 Definitions... Direction Fields... 8 Final Thoughts...19 007 Paul Dawkins i http://tutorial.math.lamar.edu/terms.aspx

More information

33. SOLVING LINEAR INEQUALITIES IN ONE VARIABLE

33. SOLVING LINEAR INEQUALITIES IN ONE VARIABLE get the complete book: http://wwwonemathematicalcatorg/getfulltextfullbookhtm 33 SOLVING LINEAR INEQUALITIES IN ONE VARIABLE linear inequalities in one variable DEFINITION linear inequality in one variable

More information

Preptests 55 Answers and Explanations (By Ivy Global) Section 4 Logic Games

Preptests 55 Answers and Explanations (By Ivy Global) Section 4 Logic Games Section 4 Logic Games Questions 1 6 There aren t too many deductions we can make in this game, and it s best to just note how the rules interact and save your time for answering the questions. 1. Type

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 21: Introduction to NP-Completeness 12/9/2015 Daniel Bauer Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways

More information

CS 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 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 information

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP) CS5371 Theory of Computation Lecture 18: Complexity III (Two Classes: P and NP) Objectives Define what is the class P Examples of languages in P Define what is the class NP Examples of languages in NP

More information

3.3 Limits and Infinity

3.3 Limits and Infinity Calculus Maimus. Limits Infinity Infinity is not a concrete number, but an abstract idea. It s not a destination, but a really long, never-ending journey. It s one of those mind-warping ideas that is difficult

More information

AST rewriting. Part I: Specifying Transformations. Imperative object programs. The need for path queries. fromentry, paths, toexit.

AST rewriting. Part I: Specifying Transformations. Imperative object programs. The need for path queries. fromentry, paths, toexit. Part I: Specifying Transformations Oege de Moor Ganesh Sittampalam Programming Tools Group, Oxford focus AST rewriting To apply rule: rewrite(pat 0, pat 1 ) Match: focus = φ(pat 0 ) Replace: focus := φ(pat

More information

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number Topic Contents Factoring Methods Unit 3 The smallest divisor of an integer The GCD of two numbers Generating prime numbers Computing prime factors of an integer Generating pseudo random numbers Raising

More information

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1 Data Flow Analysis Lecture 6 ECS 240 ECS 240 Data Flow Analysis 1 The Plan Introduce a few example analyses Generalize to see the underlying theory Discuss some more advanced issues ECS 240 Data Flow Analysis

More information

Computing Static Single Assignment (SSA) Form

Computing 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 information

Space-aware data flow analysis

Space-aware data flow analysis Space-aware data flow analysis C. Bernardeschi, G. Lettieri, L. Martini, P. Masci Dip. di Ingegneria dell Informazione, Università di Pisa, Via Diotisalvi 2, 56126 Pisa, Italy {cinzia,g.lettieri,luca.martini,paolo.masci}@iet.unipi.it

More information

COMP6463: λ-calculus

COMP6463: λ-calculus COMP6463: λ-calculus 1. Basics Michael Norrish Michael.Norrish@nicta.com.au Canberra Research Lab., NICTA Semester 2, 2015 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics

More information

Solving with Absolute Value

Solving with Absolute Value Solving with Absolute Value Who knew two little lines could cause so much trouble? Ask someone to solve the equation 3x 2 = 7 and they ll say No problem! Add just two little lines, and ask them to solve

More information

1 Maintaining a Dictionary

1 Maintaining a Dictionary 15-451/651: Design & Analysis of Algorithms February 1, 2016 Lecture #7: Hashing last changed: January 29, 2016 Hashing is a great practical tool, with an interesting and subtle theory too. In addition

More information

1 Closest Pair of Points on the Plane

1 Closest Pair of Points on the Plane CS 31: Algorithms (Spring 2019): Lecture 5 Date: 4th April, 2019 Topic: Divide and Conquer 3: Closest Pair of Points on a Plane Disclaimer: These notes have not gone through scrutiny and in all probability

More information

Analysis of Algorithms I: Perfect Hashing

Analysis of Algorithms I: Perfect Hashing Analysis of Algorithms I: Perfect Hashing Xi Chen Columbia University Goal: Let U = {0, 1,..., p 1} be a huge universe set. Given a static subset V U of n keys (here static means we will never change the

More information

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

5 + 9(10) + 3(100) + 0(1000) + 2(10000) = Chapter 5 Analyzing Algorithms So far we have been proving statements about databases, mathematics and arithmetic, or sequences of numbers. Though these types of statements are common in computer science,

More information

Path Testing and Test Coverage. Chapter 9

Path Testing and Test Coverage. Chapter 9 Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test

More information

Chapter 29 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M.

Chapter 29 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. 29 Markov Chains Definition of a Markov Chain Markov chains are one of the most fun tools of probability; they give a lot of power for very little effort. We will restrict ourselves to finite Markov chains.

More information

Register Allocation. Maryam Siahbani CMPT 379 4/5/2016 1

Register Allocation. Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Intermediate code uses unlimited temporaries Simplifying code generation and optimization Complicates final translation to assembly

More information

Path Testing and Test Coverage. Chapter 9

Path Testing and Test Coverage. Chapter 9 Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test

More information

Unit 16: Hidden Markov Models

Unit 16: Hidden Markov Models Computational Statistics with Application to Bioinformatics Prof. William H. Press Spring Term, 2008 The University of Texas at Austin Unit 16: Hidden Markov Models The University of Texas at Austin, CS

More information

Solutions. Prelim 2[Solutions]

Solutions. Prelim 2[Solutions] Prelim [Solutions]. Short Answer [ pts] (a) [ pts] A traversal of an expression tree produces the string + + 3. i. What kind of traversal is it? Preorder; the operator is printed before the operands. ii.

More information

Program verification

Program verification Program verification Data-flow analyses, numerical domains Laure Gonnord and David Monniaux University of Lyon / LIP September 29, 2015 1 / 75 Context Program Verification / Code generation: Variables

More information

Solving a Series. Carmen Bruni

Solving a Series. Carmen Bruni A Sample Series Problem Question: Does the following series converge or diverge? n=1 n 3 + 3n 2 + 1 n 5 + 14n 3 + 4n First Attempt First let s think about what this series is - maybe the terms are big

More information

Causal Dataflow Analysis for Concurrent Programs

Causal Dataflow Analysis for Concurrent Programs Causal Dataflow Analysis for Concurrent Programs Azadeh Farzan P. Madhusudan Department of Computer Science, University of Illinois at Urbana-Champaign. {afarzan,madhu}@cs.uiuc.edu Abstract. We define

More information

Linear Programming Duality

Linear Programming Duality Summer 2011 Optimization I Lecture 8 1 Duality recap Linear Programming Duality We motivated the dual of a linear program by thinking about the best possible lower bound on the optimal value we can achieve

More information

Iterative Dataflow Analysis

Iterative Dataflow Analysis Iterative Dataflow Analysis CS 352 9/24/07 Slides adapted from Nielson, Nielson, Hankin Principles of Program Analysis Key Ideas Need a mechanism to evaluate (statically) statements in a program Problem:

More information

Midterm Examination CS540: Introduction to Artificial Intelligence

Midterm Examination CS540: Introduction to Artificial Intelligence Midterm Examination CS540: Introduction to Artificial Intelligence November 1, 2005 Instructor: Jerry Zhu CLOSED BOOK (One letter-size notes allowed. Turn it in with the exam) LAST (FAMILY) NAME: FIRST

More information

Software Verification

Software Verification Software Verification Grégoire Sutre LaBRI, University of Bordeaux, CNRS, France Summer School on Verification Technology, Systems & Applications September 2008 Grégoire Sutre Software Verification VTSA

More information

MIT Loop Optimizations. Martin Rinard

MIT 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 information

hexadecimal-to-decimal conversion

hexadecimal-to-decimal conversion OTHER NUMBER SYSTEMS: octal (digits 0 to 7) group three binary numbers together and represent as base 8 3564 10 = 110 111 101 100 2 = (6X8 3 ) + (7X8 2 ) + (5X8 1 ) + (4X8 0 ) = 6754 8 hexadecimal (digits

More information

Computability Crib Sheet

Computability Crib Sheet Computer Science and Engineering, UCSD Winter 10 CSE 200: Computability and Complexity Instructor: Mihir Bellare Computability Crib Sheet January 3, 2010 Computability Crib Sheet This is a quick reference

More information

Prelim 2[Solutions] Solutions. 1. Short Answer [18 pts]

Prelim 2[Solutions] Solutions. 1. Short Answer [18 pts] Prelim [Solutions]. Short Answer [8 pts] (a) [3 pts] In a model/view/controller, Swing is likely to be part of (there may be more than one): i. the model ii. the view iii. the controller The view and the

More information

Dataflow Analysis - 2. Monotone Dataflow Frameworks

Dataflow Analysis - 2. Monotone Dataflow Frameworks Dataflow Analysis - 2 Monotone dataflow frameworks Definition Convergence Safety Relation of MOP to MFP Constant propagation Categorization of dataflow problems DataflowAnalysis 2, Sp06 BGRyder 1 Monotone

More information

Assignment 3 Logic and Reasoning KEY

Assignment 3 Logic and Reasoning KEY Assignment 3 Logic and Reasoning KEY Print this sheet and fill in your answers. Please staple the sheets together. Turn in at the beginning of class on Friday, September 8. Recall this about logic: Suppose

More information

Example: 2x y + 3z = 1 5y 6z = 0 x + 4z = 7. Definition: Elementary Row Operations. Example: Type I swap rows 1 and 3

Example: 2x y + 3z = 1 5y 6z = 0 x + 4z = 7. Definition: Elementary Row Operations. Example: Type I swap rows 1 and 3 Linear Algebra Row Reduced Echelon Form Techniques for solving systems of linear equations lie at the heart of linear algebra. In high school we learn to solve systems with or variables using elimination

More information

Great Theoretical Ideas

Great Theoretical Ideas 15-251 Great Theoretical Ideas in Computer Science Gödel s Legacy: Proofs and Their Limitations Lecture 25 (November 16, 2010) The Halting Problem A Quick Recap of the Previous Lecture Is there a program

More information

(a) Definition of TMs. First Problem of URMs

(a) Definition of TMs. First Problem of URMs Sec. 4: Turing Machines First Problem of URMs (a) Definition of the Turing Machine. (b) URM computable functions are Turing computable. (c) Undecidability of the Turing Halting Problem That incrementing

More information

Digital Circuit Engineering

Digital Circuit Engineering Digital Circuit Engineering 2nd Distributive ( + A)( + B) = + AB Circuits that work in a sequence of steps Absorption + A = + A A+= THESE CICUITS NEED STOAGE TO EMEMBE WHEE THEY AE STOAGE D MU G M MU S

More information

Recognizing Safety and Liveness by Alpern and Schneider

Recognizing Safety and Liveness by Alpern and Schneider Recognizing Safety and Liveness by Alpern and Schneider Calvin Deutschbein 17 Jan 2017 1 Intro 1.1 Safety What is safety? Bad things do not happen For example, consider the following safe program in C:

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements Axiomatic Semantics: Verification Conditions Meeting 12, CSCI 5535, Spring 2009 Announcements Homework 4 is due tonight Wed forum: papers on automated testing using symbolic execution 2 Questions? Review

More information

Lecture 10: Powers of Matrices, Difference Equations

Lecture 10: Powers of Matrices, Difference Equations Lecture 10: Powers of Matrices, Difference Equations Difference Equations A difference equation, also sometimes called a recurrence equation is an equation that defines a sequence recursively, i.e. each

More information

SECTION 2.3: LONG AND SYNTHETIC POLYNOMIAL DIVISION

SECTION 2.3: LONG AND SYNTHETIC POLYNOMIAL DIVISION 2.25 SECTION 2.3: LONG AND SYNTHETIC POLYNOMIAL DIVISION PART A: LONG DIVISION Ancient Example with Integers 2 4 9 8 1 In general: dividend, f divisor, d We can say: 9 4 = 2 + 1 4 By multiplying both sides

More information

Central Algorithmic Techniques. Iterative Algorithms

Central 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 information

Evolutionary Models. Evolutionary Models

Evolutionary Models. Evolutionary Models Edit Operators In standard pairwise alignment, what are the allowed edit operators that transform one sequence into the other? Describe how each of these edit operations are represented on a sequence alignment

More information

CS 124 Math Review Section January 29, 2018

CS 124 Math Review Section January 29, 2018 CS 124 Math Review Section CS 124 is more math intensive than most of the introductory courses in the department. You re going to need to be able to do two things: 1. Perform some clever calculations to

More information

2. Network flows. Balance of flow: At each node, demand plus total shipments out must equal supply plus total shipments in. Reno. Denver.

2. Network flows. Balance of flow: At each node, demand plus total shipments out must equal supply plus total shipments in. Reno. Denver. . Network flows A network consists of a collection of locations along with connections between them. The locations, called the nodes of the network, can correspond to places of various kinds such as factories,

More information

UNIVERSITY OF CALIFORNIA

UNIVERSITY OF CALIFORNIA UNIVERSITY OF CALIFORNIA College of Engineering Department of Electrical Engineering and Computer Sciences Last modified on April 14, 2004 by Brian Leibowitz (bsl@eecs.berkeley.edu) Jan Rabaey Homework

More information