# Compiler Design. Spring Control-Flow Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Save this PDF as:

Size: px
Start display at page:

Download "Compiler Design. Spring Control-Flow Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz"

## Transcription

1 Compiler Design Spring 2010 Control-Flow Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California Control-Flow Analysis Sample Exercises 1 Spring 2010

2 Problem1: Control-Flow Graph, Dominators and Natural Loops For the program below: 1. Determine the corresponding control flow graph. 2. Determine the dominators of each node in the CFG 3. Show the immediate dominator tree 4. Identify the set of nodes in each natural loop. Are the loops nested? Why 00: i = 0; 01: while (i < N) do 02: for(i=0; j < i; j++) 03: if(a[i] < a[j]) then 04: tmp = a[j]; 05: a[j] = a[i] 06: a[i] = tmp; 07: else 08: if(a[i] == a[j]) then 09: continue; 10: else 11: break; 12: end for 13: i = i + 1; 14: end while Note: Assume there are two entry and exit nodes corresponding to the entry point and exit points of the code segment, which would correspond to the prologue and epilogue sections of the procedure s generated code. Solution: 1. A possible control flow graph is as show on the right. 2. Node Dominators 0 {0} 1 {0, 1} 2 {0, 1, 2} 3 {0, 1, 2, 3} 4 {0, 1, 2, 3, 4} 5 {0, 1, 2, 3, 5} 6 {0, 1, 2, 3, 5, 6} 7 {0, 1, 2, 3, 5, 7} 8 {0, 1, 2, 3, 8} 9 {0, 1, 2, 3, 5, 7, 9} 10 {0, 1, 10} paths. For instance node 4 does not dominate node 8 as there is a path from the entry node that goes to node 8 and does not pass through node 4. While there is a precise algorithm to determine the dominator relationship one can find it in many simple CFG cases by inspection of control-flow Control-Flow Analysis Sample Exercises 2 Spring 2010

3 3. Immediate dominator tree edges: 0 1, 1 2, 1 10, 2 3, 3 4, 3 5, 3 8, 5 6, 5 7, Natural loops: The natural loops are determined by observing the back-edges. A back-edge is an edge in the original control-flow graph such that the node pointed to by its head dominates the node pointed to by its tail. To find a natural loop we traverse the back-edge against the control flow and all the edges in the CFG until e reach the node pointed to by the head in a breath-first traversal. Back edge Nodes in natural loop 9 1 {2, 3, 5, 7, 9} 8 2 {1, 2, 3, 4, 5, 6, 8} They are nested because they have different headers, and natural loops with different headers can either be nested or disjoint. They are not disjoint, so they must be nested. Control-Flow Analysis Sample Exercises 3 Spring 2010

4 Problem 2: Loop Induction Variables and Loop Unrolling For the program depicted below do the following: 1. Find the induction variables in this program. Show the results after applying strength reduction and loop test replacement. 2. Show the resulting code from applying loop unrolling with an unrolling factor of 2. Note: The a = *c assigns the contents of the memory location pointed to by c to a Control-Flow Analysis Sample Exercises 4 Spring 2010

5 Solution: Assuming that there is no alias among the variables, so h is not changed within the loop. Basic induction variables: {i, j} Induction variable families: {{i, d, e, k}, {j, g, c}} (We can consider h as a constant within the loop, and as a result, g will be an induction variable in the same family with j) Introduce s1 for d, s2 for e and k, s3 for g, s4 for c, and eliminate basic induction variables i and j because they are only used for calculation of other induction variables and loop test. After strength reduction and loop test replacement: s1 = -2 s2 = 0 s3 = 0 t3 = 4 * h s4 = 3 L1: s1 = s1 + 1 s2 = s2 + 2 s3 = s3 + t3 s4 = s4 + 4 b = c + 2 d = s1 c = s4 a = *c 1) After loop unrolling: s1 = -2 s2 = 0 s3 = 0 t3 = 8 * h s4 = 3 if s1 >= 4 goto L4 L1: s2 = s2 + 2 s4 = s4 + 4 c = s4 a = *c if a > 0 goto L2 s1 = s1 + 3 s2 = s2 + 6 e = s2 L2: s1 = s1 + 2 s2 = s2 + 2 s3 = s3 + t3 b = c + 2 d = s1 s4 = s4 + 4 c = s4 a = *c if a > 0 goto L3 if a > 0 goto L2 s1 = s1 + 3 s2 = s2 + 6 e = s2 L2: f = e * 2 g = s3 k = s2 if s1 < 8 goto L1 i = d + 2 j = c 3 L3: f = e * 2 g = s3 k = s2 if s1 < 4 goto L1 L4: s1 = s1 + 1 s2 = s2 + 2 s3 = s3 + t3 s4 = s4 + 4 b = c + 2 d = s1 c = s4 a = *c if a > 0 goto L5 s1 = s1 + 3 s2 = s2 + 6 e = s2 L5: f = e * 2 g = s3 k = s2 if s1 < 8 goto L4 i = d + 2 j = c s1 = s1 + 3 s2 = s2 + 6 e = s2 Control-Flow Analysis Sample Exercises 5 Spring 2010

6 Problem 3: Loops and Loop Optimizations Consider the code depicted below for a function with integer local variables i, a, b, c, d and an integer input parameters p and n. int i, a, b, c, d; 1: i = 0; 2: a = 1; 3: b = i * 4; 4: c = a + b; 5: L1: if(i > n) goto L2 6: c = a + 1; 7: i = i + 1; 8: b = i * 4; 9: if (c <= p)goto L3 10: e = 1; 11: c = e - b; 12: a = e; 13: goto L4 14: L3: d = 2; 15: c = d + b; 16: a = d; 17: L4: goto L1 18: L2: return; For this code fragment determine: 1. The Control Flow Graph (CFG). 2. The dominator tree and the loops (identify the back edges). 3. Use constant propagation to the statements in the body of the loop identified in (2). 4. Are the statements in line 8 and 16 loop invariants? Explain and describe where can they be moved to if they can in fact be moved outside any of the loops. Solution: 1. See the CFG on the left above. In the CFG each node is a basic block. Recall that a basic block is a maximal sequence of instructions such that if the first instruction of the sequence is executed so are all the instructions in the basic block. Conversely if the first instruction is not executed none of the instructions in the basic block are executed. 2. See the dominator tree on the right above. In this tree an edge indicates the notion of immediate dominance. Recall that a node p dominates another node q if and only if every path from the entry node of the code to node q has to go through node p. 3. Back edge is (5,1) since the node pointed to by its head dominates the node pointed to by its tail. The natural loop is (1,2,3,4,5). The basic blocks in this natural loop are found tracing back the back-edge against the control flow until the node pointed to by the head. In this case and regarding the edge (5,1) we would find nodes 3 and 4, then node 2 and finally node 1. The basic blocks of the natural loop induced by the back edge (5,1) would then be {1,2,3,4,5}. 4. Could remove the statement a = p1 to the head of the loop. This is only valid because a is not live at the end of the loop so even if the original loop were never to execute and since the head of the loop would execute once this transformation would still be correct. Control-Flow Analysis Sample Exercises 6 Spring 2010

7 Problem 4: Algebraic Transformations For the code below apply the following code transformations: constant propagation, constant folding, copypropagation, dead-code elimination and strength reduction. t1 = t1 + 1 L0: t2 = 0 t3 = t1 * t4 = t3 + t2 t5 = t4 * 4 t6 = *t5 t7 = FP + t3 *t7 = t2 t8 = t1 if (t8 > 0) goto L1 L1: goto L0 L2: t1 = 1 t10 = 16 t11 = t1 * 2 goto L1 Answers: The code in red is unreachable and can thus be eliminated. The goto L1 in the end is a goto to another goto instruction and thus can be converted into a goto L0 instruction. t1 = t1 + 1 L0: t2 = 0 t3 = t1 * t4 = t3 + t2 t5 = t4 * 4 t6 = *t5 t7 = FP + t3 *t7 = t2 t8 = t1 if (t8 > 0) goto L0 L1: goto L0 L2: t1 = 1 t10 = 16 t11 = t1 * 2 goto L1 after dead-code elimination t1 = t1 + 1 L0: t2 = 0 t3 = (t1 << 3) + 1 t4 = t3 t5 = (t4 << 2) t6 = *t5 t7 = FP + t3 *t7 = t2 t8 = t1 if (t8 > 0) goto L0 after symbolic propagation for (t2 = 0) and strength reduction of the various multiplications by 4 and 8. t1 = t1 + 1 L0: t2 = 0 t3 = (t1 << 3) + 1 t4 = t3 t5 = (t3 << 2) t6 = *t5 t7 = FP + t3 *t7 = t2 t8 = t1 if (t1 > 0) goto L0 after copy propagation; now we can eliminate the variables t8 and t4 and t2 as they are never used in this code. In reality you can also see that t1 is now loop invariant and so is the sub-expression (t1 <<3) + 1 which can now be hoisted outside the loop. Along the same reasoning t5 is also loop invariant and so is everything else. This is a very uninteresting example. Control-Flow Analysis Sample Exercises 7 Fall 2009

8 Problem 5: Control-Flow Graph Analysis and Data-Flow Analysis 01 a = 1 02 b = 2 03 L0: c = a + b 04 d = c - a 05 if c < d goto L2 06 L1: d = b + d 07 if d < 1 goto L3 08 L2: b = a + b 09 e = c a 10 if e == 0 goto L0 11 a = b + d 12 b = a d 13 goto L4 14 L3: d = a + b 15 e = e goto L1 17 L4: return For the code shown above, determine the following: a) The basic blocks of instructions and the control-flow graph (CFG). b) The live variables at the end of each basic block. You do not need to determine the live variables before and after each basic block and justify your answer for the value presented for the basic block containing instructions at line 6 and 7. c) Is the live variable analysis a forward or backward data-flow analysis problem? Why and what does guarantee its termination when formulated as a data-flow analysis iterative problem? Answers: a) We indicate the instructions in each basic block and the CFG and dominator tree on the RHS. BB1: {01, 02} BB2: {03, 04, 05} BB3: {06, 07} BB4: {08, 09, 10} BB5: {11, 12, 13} BB6: {14, 15, 16} Control-Flow Analysis Sample Exercises 8 Spring 2010

9 b) The def-use chains can be obtained by inspection of which definitions are not killed along all path from its definition point to the use points. For example for variable a definition at the instruction 1, denoted by a1 reaches the use points at the instructions 3, 4, 8, 9 and 15, hence the notation {d1, u3, u4, u8, u9, 15}. Definition a1 does not reach use u12 because there is another definition at 11 that masks it, hence another du chain for a denoted as {d11, u12}. The complete list is shown below. a: {d1, u3, u4, u8, u9, u15} a: {d11, u12} b: {d2, u3, u4, u6, u14, u8} b: {d8, u11, u8, u14} b: {d12} c: {d3, u4, u5, u9} d: {d4, u5, u6} d: {d6, u7} d: {d14, u6} e: {d9, u10, u15} e: {d14, u15} e: {d14, u6} At the end of each basic block we can inspect the code and ask if a given variable is still used after the control flow leaves that basic block. The results of this inspection is depicted below: BB1: {a, b} BB2: {a, b, c, d, e} BB3: {a, b, c, d, e} BB4: {a, b, d, e} BB5: { } BB6: {a, b, c, d, e} For BB6 the live variable solution at the exit of this basic block has {a, b, c, d, e} as there exists a path after BB6 where all the variables are being used. For example variable e is used in the basic block following the L1 label and taking the jump to L3 to BB6 again where is used before being redefined. c) The live variable analysis is a backward data-flow problem as we propagate the information about a future use of a variable backward to specific points of the program. If there is a definition at a specific point backward the solution kills all other uses and resets the information associated with that variable. As with many other iterative formulations of data-flow analysis problems termination is guaranteed by the fact that the lattice, in this case the set of variables, has finite cardinality or length. The flow-function, in this case set-union is monotonic. Control-Flow Analysis Sample Exercises 9 Fall 2009

10 Problem 6: Control-Flow Graph Analysis and Data-Flow Analysis 01 func: a = 1 02 b = 2 03 L0: c = a + b 04 d = c - a 05 if c < d goto L2 06 d = b + d 07 if d < 1 goto L3 08 L2: b = a + b 09 e = c a 10 if e == 0 goto L0 11 a = b + d 12 b = a d 13 goto L1 14 L3: d = a + b 15 e = e goto L2 17 L1: return For the code shown on the left, determine the following: a) The basic blocks of instructions identifying the instructions that constitutes each basic block. Clearly identify the leader instruction of each basic block. b) The control-flow graph (CFG) and the corresponding dominator tree. c) For each variable, its use-def chains. d) The set of available expressions at the beginning of each basic block. You do not need to compute the DFA solution at each step of the iterative formulation but rather argue that your solution is correct by explaining the specific Available Expressions DFA problem. e) Is the Available Expressions DFA a forward or backward data-flow analysis problem? Why and what does guarantee its termination when formulated as a data-flow analysis iterative problem? Answers: a) The basic blocks of instructions identifying the instructions that constitutes each basic block. Clearly identify the leader instruction of each basic block. b) The control-flow graph (CFG) and the corresponding dominator tree. See the answer to both these questions below where the leader of each basic block is in bold font. Control-Flow Analysis Sample Exercises 10 Spring 2010

11 c) For each variable, its use-def chain. For each variable we indicate for a given definition d its uses u as the line numbers in which they occur. a: {d1, u3, u4, u8, u9} {d11, u12} {d1, u3, u4, u14} b: {d2, u3, u6, u8} {d8, u11} {d8, u3, u6, u8} c: {d3, u4, u5, u9} d: {d4, u5, u11, u12} {d6, u7, u11, u12} e: {d9, u10, u15} {d15} d) The set of available expressions at the beginning of each basic block. You do not need to compute the DFA solution at each step of the iterative formulation but rather argue that your solution is correct by explaining the specific Available Expressions DFA problem. Justify your answer by showing the GEN and KILL sets of each of the basic blocks. The set of expressions in the program are outlined below on the left. On the right we have for each Basic Block BB0 through BB6 we have the following GEN and KILL sets. (1): (a+b) line 3 (2): (c-a) line 4 (3): (b+d) line 6 (4): (e+1) line 15 (5): (a-d) line 12 (6): (a+b) line 8 (7): (c-a) line 9 (8): (a+b) line 14 (9): (b+d) line 11 BB0: gen = { }, kill = {1,2,3,5,6,7,8,9} BB1: gen = {1,2}, kill = {2,3,5,7,9} BB2: gen = {3}, kill = {3,5,9} BB3: gen = {4,8}, kill = {3,4,5,9} BB4: gen = {6,7}, kill = {1,3,4,6,8,9} BB5: gen = {5,9}, kill = {1,2,3,5,6,7,8,9} BB6: gen = { }, kill = { } Applying the iterative fixed-point computation with set intersection corresponding to this problem s DFA formulation as described in class we would arrive at the following final solution for the set of available expression at the input of each basic block: BB0: {1,2,3,4,5,6,7,8,9}by definition BB1: {4} BB2: {1,2,4} BB3: {1,2,3,4} BB4: {2,4} BB5: {2,4} BB6: {4,5,9} Recall that for each basic block the input is the intersection of the outputs of all its predecessors and the output of each basic block is computed by the data-flow equation out = gen + (in kill). e) Is the Available Expressions DFA a forward or backward data-flow analysis problem? Why and what does guarantee its termination when formulated as a data-flow analysis iterative problem? This DFA problem is a forward data-flow problem as the expression become un-available as soon as one of its operands is redefined. At the beginning no expressions are available as they are generated as soon as the expression that defined them are encountered. A given expression is only available at a specific execution point is all path leading to that specific point have that expression available. As such the meet function is the set intersection. With an initial solution of the set of all available expressions (except for the initial node whose initial solution is empty) and applying the set intersection operation, given that the number of expressions is finite the iterative application of the set intersection will eventually converge. Hence the termination of the fixedpoint computation is guaranteed. Control-Flow Analysis Sample Exercises 11 Fall 2009

### Lecture 2 Introduction to Data Flow Analysis

Lecture 2 Introduction to Data Flow Analysis I. Introduction II. Example: Reaching definition analysis III. Example: Liveness analysis IV. A General Framework (Theory in next lecture) Reading: Chapter

### CIS570 Lecture 9 Reuse Optimization II 3

Reuse Optimization Last time Discussion (SCC) Loop invariant code motion Reuse optimization: Value numbering Today More reuse optimization Common subexpression elimination (CSE) Partial redundancy elimination

### Optimizations. Optimization Safety. Optimization Safety. Control Flow Graphs. Code transformations to improve program

Optimizations Code transformations to improve program Mainly: improve execution time Also: reduce program size Control low Graphs Can be done at high level or low level E.g., constant folding Optimizations

### 2) Write in detail the issues in the design of code generator.

COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage

### CSE 504: Compiler Design. Data Flow Analysis

Data Flow Analysis Pradipta De pradipta.de@sunykorea.ac.kr Current Topic Iterative Data Flow Analysis LiveOut sets Static Single Assignment (SSA) Form Data Flow Analysis Techniques to reason about runtime

### Introduction to Data-flow analysis

Introduction to Data-flow analysis Last Time LULESH intro Typed, 3-address code Basic blocks and control flow graphs LLVM Pass architecture Data dependencies, DU chains, and SSA Today CFG and SSA example

### Lecture 10 Partial Redundancy Elimination

References Lecture 10 Partial Redundancy Elimination Global code motion optimization Remove partially redundant expressions Loop invariant code motion Can be extended to do Strength Reduction No loop analysis

### Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007

Constant Propagation Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007 Osnat Minz and Mati Shomrat Introduction This

### Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

### Algorithms and Data Structures

Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2

### 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

Obfuscation: know your enemy Ninon EYROLLES neyrolles@quarkslab.com Serge GUELTON sguelton@quarkslab.com Prelude Prelude Plan 1 Introduction What is obfuscation? 2 Control flow obfuscation 3 Data flow

### Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

### Software Analysis (POPA Sec , )

Software Analysis (POPA Sec. 2.2.2, 2.5-2.5.2) Klaus Ostermann Based on slides by Jurriaan Hage Overview Correctness proof Live Variables Analysis The While language with procedures Live Variables Analysis

### An Overview of a Compiler

An Overview of a Compiler Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Outline of the Lecture About the course

### Interprocedural Analysis. CS252r Spring 2011

Interprocedural Analysis CS252r Spring 2011 Procedures So far looked at intraprocedural analysis: analyzing a single procedure Interprocedural analysis uses calling relationships among procedures Enables

### Graph Theory Problems and Solutions

raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

### CLAPP: Characterizing Loops in Android Applications

CLAPP: Characterizing Loops in Android Applications Yanick Fratantonio UC Santa Barbara, USA yanick@cs.ucsb.edu Christopher Kruegel UC Santa Barbara, USA chris@cs.ucsb.edu Aravind Machiry UC Santa Barbara,

### 1. The algebra of exponents 1.1. Natural Number Powers. It is easy to say what is meant by a n a (raised to) to the (power) n if n N.

CHAPTER 3: EXPONENTS AND POWER FUNCTIONS 1. The algebra of exponents 1.1. Natural Number Powers. It is easy to say what is meant by a n a (raised to) to the (power) n if n N. For example: In general, if

### Why? A central concept in Computer Science. Algorithms are ubiquitous.

Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

### ABCD: Eliminating Array Bounds Checks on Demand

ABCD: Eliminating Array Bounds Checks on Demand Rastislav Bodík Rajiv Gupta Vivek Sarkar University of Wisconsin bodik@cswiscedu University of Arizona gupta@csarizonaedu IBM TJ Watson Research Center vsarkar@usibmcom

### Automatic Test Data Synthesis using UML Sequence Diagrams

Vol. 09, No. 2, March April 2010 Automatic Test Data Synthesis using UML Sequence Diagrams Ashalatha Nayak and Debasis Samanta School of Information Technology Indian Institute of Technology, Kharagpur

### Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Module No. # 02 Lecture No. # 05 Run-time Environments-Part 3 and Local Optimizations

### CS510 Software Engineering

CS510 Software Engineering Dynamic Program Analysis Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-cs510-se

### Statistical Machine Translation: IBM Models 1 and 2

Statistical Machine Translation: IBM Models 1 and 2 Michael Collins 1 Introduction The next few lectures of the course will be focused on machine translation, and in particular on statistical machine translation

### Why have SSA? Birth Points (cont) Birth Points (a notion due to Tarjan)

Why have SSA? Building SSA Form SSA-form Each name is defined exactly once, thus Each use refers to exactly one name x 17-4 What s hard? Straight-line code is trivial Splits in the CFG are trivial x a

### 12 Abstract Data Types

12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

### Repetition and Loops. Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed.

New Topic Repetition and Loops Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed. These constructs are the 1. while loop and

### The Graphical Method: An Example

The Graphical Method: An Example Consider the following linear program: Maximize 4x 1 +3x 2 Subject to: 2x 1 +3x 2 6 (1) 3x 1 +2x 2 3 (2) 2x 2 5 (3) 2x 1 +x 2 4 (4) x 1, x 2 0, where, for ease of reference,

### Static Data Race Detection for Concurrent Programs with Asynchronous Calls

Static Data Race Detection for Concurrent Programs with Asynchronous Calls Vineet Kahlon NEC Labs America, Princeton, USA. Nishant Sinha NEC Labs America Princeton, USA. Erik Kruus NEC Labs America Princeton,

### Lecture Notes on Static Analysis

Lecture Notes on Static Analysis Michael I. Schwartzbach BRICS, Department of Computer Science University of Aarhus, Denmark mis@brics.dk Abstract These notes present principles and applications of static

### Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

Today s Agenda Quiz 4 Temporal Logic Formal Methods in Software Engineering 1 Automata and Logic Introduction Buchi Automata Linear Time Logic Summary Formal Methods in Software Engineering 2 1 Buchi Automata

### Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

### Automata and Computability. Solutions to Exercises

Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

### 1 if 1 x 0 1 if 0 x 1

Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

### Chapter One Introduction to Programming

Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

### Representation and Analysis of Software

Representation and Analysis of Software Mary Jean Harrold Gregg Rothermel Alex Orso Georgia ech Oregon State University Georgia ech 1 Introduction his paper presents some basic techniques for representation

### Math 115 Spring 2011 Written Homework 5 Solutions

. Evaluate each series. a) 4 7 0... 55 Math 5 Spring 0 Written Homework 5 Solutions Solution: We note that the associated sequence, 4, 7, 0,..., 55 appears to be an arithmetic sequence. If the sequence

### Symbol Tables. Introduction

Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

### Software Engineering PhD Qualifying Examination October 28, 2010

Software Engineering PhD Qualifying Examination October 28, 2010 Rules: Answer six of the following nine questions including questions 1 and 2. Include citations for relevant literature where appropriate,

### Static Analysis. Find the Bug! 15-654: Analysis of Software Artifacts. Jonathan Aldrich. disable interrupts. ERROR: returning with interrupts disabled

Static Analysis 15-654: Analysis of Software Artifacts Jonathan Aldrich 1 Find the Bug! Source: Engler et al., Checking System Rules Using System-Specific, Programmer-Written Compiler Extensions, OSDI

### Reading 13 : Finite State Automata and Regular Expressions

CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

### AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm

AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm Time: Three Hours] [Maximum Marks: 60 Note Attempts all the questions. All carry equal marks Section A

### Lecture 3: Linear Programming Relaxations and Rounding

Lecture 3: Linear Programming Relaxations and Rounding 1 Approximation Algorithms and Linear Relaxations For the time being, suppose we have a minimization problem. Many times, the problem at hand can

### Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

### 7.1 Our Current Model

Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.

### 9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending

### Applications of Methods of Proof

CHAPTER 4 Applications of Methods of Proof 1. Set Operations 1.1. Set Operations. The set-theoretic operations, intersection, union, and complementation, defined in Chapter 1.1 Introduction to Sets are

### Examples and Proofs of Inference in Junction Trees

Examples and Proofs of Inference in Junction Trees Peter Lucas LIAC, Leiden University February 4, 2016 1 Representation and notation Let P(V) be a joint probability distribution, where V stands for a

### Model Checking: An Introduction

Announcements Model Checking: An Introduction Meeting 2 Office hours M 1:30pm-2:30pm W 5:30pm-6:30pm (after class) and by appointment ECOT 621 Moodle problems? Fundamentals of Programming Languages CSCI

### How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

How to make the computer understand? Fall 2005 Lecture 15: Putting it all together From parsing to code generation Write a program using a programming language Microprocessors talk in assembly language

### Introduction to Computers and Programming. Testing

Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 13 April 16 2004 Testing Goals of Testing Classification Test Coverage Test Technique Blackbox vs Whitebox Real bugs and software

### 2.3 Scheduling jobs on identical parallel machines

2.3 Scheduling jobs on identical parallel machines There are jobs to be processed, and there are identical machines (running in parallel) to which each job may be assigned Each job = 1,,, must be processed

### Object Oriented Software Design

Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

### The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical

### Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links)

Class 9 Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links) Readings on pointer analysis Problem Set 5: due 9/22/09 Project proposal

### The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

The Tower of Hanoi Recursion Solution recursion recursion recursion Recursive Thinking: ignore everything but the bottom disk. 1 2 Recursive Function Time Complexity Hanoi (n, src, dest, temp): If (n >

### GENERIC and GIMPLE: A New Tree Representation for Entire Functions

GENERIC and GIMPLE: A New Tree Representation for Entire Functions Jason Merrill Red Hat, Inc. jason@redhat.com 1 Abstract The tree SSA project requires a tree representation of functions for the optimizers

### ML-Flex Implementation Notes

ML-Flex Implementation Notes Aaron Turon adrassi@uchicago.edu February 17, 2006 Contents 1 Organization 2 2 Theory 3 2.1 Regular expressions................................ 3 2.2 Derivatives.....................................

### Module: Software Instruction Scheduling Part I

Module: Software Instruction Scheduling Part I Sudhakar Yalamanchili, Georgia Institute of Technology Reading for this Module Loop Unrolling and Instruction Scheduling Section 2.2 Dependence Analysis Section

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding

### CMPS 102 Solutions to Homework 1

CMPS 0 Solutions to Homework Lindsay Brown, lbrown@soe.ucsc.edu September 9, 005 Problem..- p. 3 For inputs of size n insertion sort runs in 8n steps, while merge sort runs in 64n lg n steps. For which

### Intro. to the Divide-and-Conquer Strategy via Merge Sort CMPSC 465 CLRS Sections 2.3, Intro. to and various parts of Chapter 4

Intro. to the Divide-and-Conquer Strategy via Merge Sort CMPSC 465 CLRS Sections 2.3, Intro. to and various parts of Chapter 4 I. Algorithm Design and Divide-and-Conquer There are various strategies we

### EECS 583 Class 11 Instruction Scheduling Software Pipelining Intro

EECS 58 Class Instruction Scheduling Software Pipelining Intro University of Michigan October 8, 04 Announcements & Reading Material Reminder: HW Class project proposals» Signup sheet available next Weds

### YOU CAN COUNT ON NUMBER LINES

Key Idea 2 Number and Numeration: Students use number sense and numeration to develop an understanding of multiple uses of numbers in the real world, the use of numbers to communicate mathematically, and

### Special Situations in the Simplex Algorithm

Special Situations in the Simplex Algorithm Degeneracy Consider the linear program: Maximize 2x 1 +x 2 Subject to: 4x 1 +3x 2 12 (1) 4x 1 +x 2 8 (2) 4x 1 +2x 2 8 (3) x 1, x 2 0. We will first apply the

### Questions and Answers in Computer Science. By Yonas Tesfazghi Weldeselassie http://www.ictp.trieste.it/ weldesel

Questions and Answers in Computer Science By Yonas Tesfazghi Weldeselassie http://www.ictp.trieste.it/ weldesel The Questions in this material are collected from Computer Science Subject Graduate Record

### Data Structures and Algorithms Written Examination

Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where

### Lecture 12 Doubly Linked Lists (with Recursion)

Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)

### Informatics 2D Reasoning and Agents Semester 2, 2015-16

Informatics 2D Reasoning and Agents Semester 2, 2015-16 Alex Lascarides alex@inf.ed.ac.uk Lecture 30 Markov Decision Processes 25th March 2016 Informatics UoE Informatics 2D 1 Sequential decision problems

### Efficiently Monitoring Data-Flow Test Coverage

Efficiently Monitoring Data-Flow Test Coverage Raul Santelices and Mary Jean Harrold Georgia Institute of Technology College of Computing Atlanta, Georgia, USA 30332 {raul harrold}@cc.gatech.edu ABSTRACT

### Object Oriented Software Design

Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

### Software Development Method

Software Development Method Problem Analysis - (Correct Problem) Identify data objects Goal to model properties Determine Input / Output data Constraints on the problem Design Decompose into smaller problems

### Scheduling Shop Scheduling. Tim Nieberg

Scheduling Shop Scheduling Tim Nieberg Shop models: General Introduction Remark: Consider non preemptive problems with regular objectives Notation Shop Problems: m machines, n jobs 1,..., n operations

### Semantic Analysis: Types and Type Checking

Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

### INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS

INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS STEVEN P. LALLEY AND ANDREW NOBEL Abstract. It is shown that there are no consistent decision rules for the hypothesis testing problem

### A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

PLDI 03 A Static Analyzer for Large Safety-Critical Software B. Blanchet, P. Cousot, R. Cousot, J. Feret L. Mauborgne, A. Miné, D. Monniaux,. Rival CNRS École normale supérieure École polytechnique Paris

### Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz 2007 03 16

Advanced compiler construction Michel Schinz 2007 03 16 General course information Teacher & assistant Course goals Teacher: Michel Schinz Michel.Schinz@epfl.ch Assistant: Iulian Dragos INR 321, 368 64

### A Fresh Look at Optimizing Array Bound Checking

A Fresh Look at Optimizing Array Bound Checking Rajiv Gupta Philips Laboratories North American Philips Corporation 345 Scarborough Road Briarcliff Manor, NY 10510 E-mail: gupta@philabs.philips.com Abstract

### GameTime: A Toolkit for Timing Analysis of Software

GameTime: A Toolkit for Timing Analysis of Software Sanjit A. Seshia and Jonathan Kotker EECS Department, UC Berkeley {sseshia,jamhoot}@eecs.berkeley.edu Abstract. Timing analysis is a key step in the

### Introduction and Rationale

Outline 1 Introduction 2 3 Making it Work 4 5 Introduction and Rationale Introduction Last time we saw flow sensitive points-to analysis Computes information at every point of a program Precise The information

### µz An Efficient Engine for Fixed points with Constraints

µz An Efficient Engine for Fixed points with Constraints Kryštof Hoder, Nikolaj Bjørner, and Leonardo de Moura Manchester University and Microsoft Research Abstract. The µz tool is a scalable, efficient

### Lecture 6 Online and streaming algorithms for clustering

CSE 291: Unsupervised learning Spring 2008 Lecture 6 Online and streaming algorithms for clustering 6.1 On-line k-clustering To the extent that clustering takes place in the brain, it happens in an on-line

### 6.3 Conditional Probability and Independence

222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

### Software Testing. Jeffrey Carver University of Alabama. April 7, 2016

Software Testing Jeffrey Carver University of Alabama April 7, 2016 Warm-up Exercise Software testing Graphs Control-flow testing Data-flow testing Input space testing Test-driven development Introduction

### Testing LTL Formula Translation into Büchi Automata

Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland

### Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Tutorial#1 Q 1:- Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2:- What is a Data Type? Differentiate

### Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

Algorithms Efficiency of algorithms Computational resources: time and space Best, worst and average case performance How to compare algorithms: machine-independent measure of efficiency Growth rate Complexity

### Overview. Essential Questions. Precalculus, Quarter 4, Unit 4.5 Build Arithmetic and Geometric Sequences and Series

Sequences and Series Overview Number of instruction days: 4 6 (1 day = 53 minutes) Content to Be Learned Write arithmetic and geometric sequences both recursively and with an explicit formula, use them

### HOTPATH VM. An Effective JIT Compiler for Resource-constrained Devices

HOTPATH VM An Effective JIT Compiler for Resource-constrained Devices based on the paper by Andreas Gal, Christian W. Probst and Michael Franz, VEE 06 INTRODUCTION INTRODUCTION Most important factor: speed

### The Trip Scheduling Problem

The Trip Scheduling Problem Claudia Archetti Department of Quantitative Methods, University of Brescia Contrada Santa Chiara 50, 25122 Brescia, Italy Martin Savelsbergh School of Industrial and Systems

### Absolute Value Equations and Inequalities

Key Concepts: Compound Inequalities Absolute Value Equations and Inequalities Intersections and unions Suppose that A and B are two sets of numbers. The intersection of A and B is the set of all numbers

### Coverability for Parallel Programs

2015 http://excel.fit.vutbr.cz Coverability for Parallel Programs Lenka Turoňová* Abstract We improve existing method for the automatic verification of systems with parallel running processes. The technique

### ALGORITHM AND FLOW CHART

ALGORITHM AND FLOW CHART 1.1 Introduction 1.2 Problem Solving 1.3 Algorithm 1.3.1 Examples of Algorithm 1.3.2 Properties of an Algorithm 1.4 Flow Chart 1.4.1 Flow Chart Symbols 1.4.2 Some Flowchart Examples

### SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis

SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis M. Vidyasagar Cecil & Ida Green Chair The University of Texas at Dallas Email: M.Vidyasagar@utdallas.edu October 17, 2015 Outline

### Introduction to Programming in C++: Algorithms, Flowcharts and Pseudocode

Introduction to Programming in C++: Algorithms, Flowcharts and Pseudocode by Brent Daviduck The following material was developed by Brent Daviduck of the Computer Systems Technology program at Red Deer

### CHAPTER 4 THE PARALLEL ALGORITHM FOR DETECTION AND EXECUTION OF ARITHMETIC OPERATIONS AT INTRAINSTRUCTION LEVEL

39 CHAPTER 4 THE PARALLEL ALGORITHM FOR DETECTION AND EXECUTION OF ARITHMETIC OPERATIONS AT INTRAINSTRUCTION LEVEL In this chapter the relevant work of parallelism exploitation within a single statement