Overview Of Op*miza*on, 2
|
|
- Corey Potter
- 6 years ago
- Views:
Transcription
1 OMP 512 Rice University Spring 2015 Overview Of Op*miza*on, 2 Superlocal Value Numbering, SE opyright 2015, Keith D. ooper & Linda Torczon, all rights reserved. Students enrolled in omp 512 at Rice University have explicit permission to make copies of these materials for their personal use. aculty from other educahonal inshtuhons may use these materials for nonprofit educahonal purposes, provided this copyright nohce is preserved itahon numbers, when given, refer to entries in the Ea2e bibliography.
2 Local Value Numbering Review The algorithm or each operahon o in the block 1 et value numbers for the operands from a hash lookup 2 Hash <operator,vn(o 1 ),VN(o 2 )> to get a value number for o 3 If o already had a value number, replace o with a reference 4 If o 1 & o 2 are constant, evaluate it & use a load immediate If hashing behaves, the algorithm runs in linear Hme If you don t believe in hashing, try mulh- set discriminahon Minor issues ommutahve operator hash operands in each order or sort the operands by VN before hashing (either works, sor;ng is cheaper ) Looks at operand s value number, not its name Ea2e: digression on page 256 or reference [65] OMP 512, Spring
3 Mul9- lock Example Review ontrol- flow graph () Nodes for basic blocks Edges for branches asis for much of program analysis & transformahon = (N,E) N = {,,, D, E,, } E = { (,), (,), (,),(,D), (,E), (D,), (E,), (,E) } N = 7, E = 8 OMP 512, Spring
4 Mul9- lock Example Review Local Value Numbering (LVN) 1 block at a Hme Strong local results No inter- block effects LVN finds redundant ops in red OMP 512, Spring
5 Mul9- lock Example Review Local Value Numbering (LVN) 1 block at a Hme Strong local results No inter- block effects LVN finds redundant ops in red LVN misses redundant ops in blue OMP 512, Spring
6 eyond asic locks: Extended asic locks Review n Extended asic lock (E) Set of blocks 1, 2,, n 1 has > 1 predecessor ll other i have 1 pred. & that pred. is in the E OMP 512, Spring
7 Extended asic locks Review n Extended asic lock (E) Set of blocks 1, 2,, n 1 has > 1 predecessor ll other i have 1 pred. & that pred. is in the E Three Es in this 1. {,,, D, E} OMP 512, Spring
8 Extended asic locks Review n Extended asic lock (E) Set of blocks 1, 2,, n 1 has > 1 predecessor ll other i have 1 pred. & that pred. is in the E Three Es in this 1. {,,, D, E } 2. { } OMP 512, Spring
9 Extended asic locks Review n Extended asic lock (E) Set of blocks 1, 2,, n 1 has > 1 predecessor ll other i have 1 pred. & that pred. is in the E Three Es in this 1. {,,, D, E } 2. { } 3. { } OMP 512, Spring
10 Extended asic locks Review n Extended asic lock (E) Set of blocks 1, 2,, n 1 has > 1 predecessor ll other i have 1 pred. & that pred. is in the E Three Es in this 1. {,,, D, E } 2. { } 3. { } Degenerate or trivial Es OMP 512, Spring
11 Value Numbering Over Extended asic locks Review Superlocal VN (SVN) pply LVN to each path in E arry hash table forward, block to block pply LVN to each path in E 1. (, ) OMP 512, Spring
12 Value Numbering Over Extended asic locks Review Superlocal VN pply LVN to each path in E arry hash table forward, block to block pply LVN to each path in E 1. (, ) 2. (,, D) OMP 512, Spring
13 Value Numbering Over Extended asic locks Review Superlocal VN pply LVN to each path in E arry hash table forward, block to block pply LVN to each path in E 1. (, ) 2. (,, D) 3. (,, E) OMP 512, Spring
14 Superlocal Value Numbering Efficiency Easy to implement if we are willing to process three Hmes & twice,,,, D,,, E,, ould be faster if we reused the results from &,,, D, E,, OMP 512, Spring
15 Superlocal Value Numbering Efficiency Easy to implement if we are willing to process three Hmes & twice,,,, D,,, E,, ould be faster if we reused the results from &,,, D, E,, Worst ase Imagine SVN on a case statement n- 1 n OMP 512, Spring
16 The Role of Names in Superlocal Value Numbering What work must be repeated in a predecessor block? Value numbers are stored in a hash table Keyed by name or <op,vn,vn> construct To avoid repeated work, SVN should roll back changes to the hash table Rather than,,, we want to go from to without revisihng x c + d x a + b In the example, the definihon of x in changes the hash table entry for x oer, SVN needs to roll x s value number back to the value from ould run backward through and undo each definihon (with bookkeeping) ould reprocess eper way is to rename so that each definihon has a unique name y a + b We saw the same issue in LVN, in local register alloca*on, & in local scheduling. We need a global name space with the right set of properhes OMP 512, Spring
17 Superlocal Value Numbering Efficiency Easy to implement if we are willing to process three Hmes & twice,,,, D,,, E,, ould be faster if we reused the results from &,,, D, E,, Need an appropriate name space & a scoped hash table (parsing? ) lterna*ve is to add lots of complex mechanism for kills & table management Desired Name Space Unique name for each definihon Name VN SS name space is ideal OMP 512, Spring 2015 Scoped Table? 5.5 in Ea2e 17
18 side: SS Name Space (In eneral) Two principles Each name is defined by exactly one operahon Each operand refers to exactly one definihon To reconcile these principles with real code Insert φ- funchons at merge points to reconcile name space dd subscripts to variable names for uniqueness φ- funchon selects one of its operands, based on the control- flow path used to reach the block. x... x x +... becomes x 0... x 1... x 2 φ(x 0,x 1 ) x We ll look at how to construct SS form in a week or two OMP 512, Spring
19 Superlocal Value Numbering Now, SVN becomes 1. IdenHfy Es 2. In depth- first order over an E, starhng with the head of the E, b 0 a. pply LVN to b i b. Invoke SVN on each of b i s E successors When going from b i to its E successor b j, extend the symbol table with a new scope for b j, apply LVN to b j, & process b j s E successors When going from b j to its E predecessor b i, discard the scope for b j It is that easy, with a scoped table & the right name space OMP 512, Spring
20 SVN on the Example LVN finds redundant ops in red SVN finds redundant ops in blue OMP 512, Spring
21 SVN on the Example LVN finds redundant ops in red SVN finds redundant ops in blue oth miss redundancies in & OMP 512, Spring
22 Perspec9ve SVN sidesteps the need for separate analysis & transforma9on pplies LVN over a larger acyclic context long a path in an E, order is fully specified Direct contrast with scheduling in an E or a trace, because scheduling moves around operahons and changes the order Result, in scheduling, is compensa;on code Redundancy eliminahon preserves the order, so we can stretch LVN to Es To go (much) beyond Es, we need separate transforma9on & analysis Later in the semester, we will look at methods that combine code mo;on & redundancy elimina;on, such as lazy code mo;on [225,133], and at a technique that applies HopcroL s par;;oning algorithm to expressions over SS names [22]. ut first, we will look at the classical formulahon of global common subexpression elimina;on based on the global data- flow problem: available expressions [218] OMP 512, Spring
23 lobal ommon Subexpression Elimina9on (SE) The oal ind redundant expressions ( common subexpressions ) whose range spans mulhple basic blocks, and eliminate any unnecessary re- evaluahons Safety ormulate availability of a redundant expression at point p as a data- flow problem: available expressions (annotate each block b with a set VIL(b) ) If x VIL(b), then, along each path from the entry to block b, x is evaluated and its conshtuent subexpressions (i.e., operands) are not redefined EvaluaHng x at the start of b would produce the same answer as at its most recent evaluahon, along any path leading from the entry to b TransformaHon preserves the result of prior computahons and uses them Only replaces an evaluahon that is in the VIL set of its block & shll available at the point of evaluahon SE does not move evaluahons, it eliminates them Safety of SE hinges on the correctness of the VIL sets OMP 512, Spring 2015 This treatment follows ocke s classic paper [87]. 23
24 lobal ommon Subexpression Elimina9on The oal ind redundant expressions ( common subexpressions ) whose range spans mulhple basic blocks, and eliminate any unnecessary re- evaluahons Profitability The transformahon does not add any new evaluahons to the code The transformahon replaces the evaluahon of the redundant expression with a register- to- register copy from a preserved value opy operahons are inexpensive Many copies will coalesce away The transformahon can increase or decrease demand for registers If the redundant expression is the last use of one of its operands, it may reduce register pressure Difficult to understand the impact of any given replacement on register pressure OMP 512, Spring
25 vailable Expressions or each block b Let VIL(b) be the set of expressions available on entry to b IniHally, VIL(n) = { all expressions }, n N, except n 0 IniHally, VIL(n 0 ) = Ø Let EXPRKILL(b) be the set of expressions killed in b Let DEEXPR(b) be the set of expressions defined in b and not subsequently killed in b (downward- exposed expressions) Now, VIL(b) can be defined as: complement operator VIL(b) = x preds(b) (DEEXPR(x) (VIL(x) EXPRKILL(x))) where preds(b) is the set of b s predecessors in the control- flow graph This system of simultaneous equahons forms a data- flow problem Solve it with a data- flow algorithm (e.g., itera;ve fixed- point scheme) OMP 512, Spring
26 Using vailable Expressions for SE The Method 1. uild a control- flow graph () 2. block b, compute DEEXPR(b) and EXPRKILL(b) & inihalize VIL(b) 3. block b, compute VIL(b) Expressions killed in b Downward- exposed expressions 4. block b, replace expressions that are available with references Two key issues ompuhng VIL(b) Managing the replacement process We ll look at the replacement issue first ssume, without loss of generality (wlog), that we can compute VIL(b) correctly OMP and efficiently 512, Spring for 2015 each block b. 26
27 Replacement in SE The key lies in managing the name space Need a unique name e VIL(b) 1. an generate them as replacements are done (ortran H) 2. an pre- compute a stahc mapping (lassic answer) 3. an encode value numbers into names (Simpson) Strategy 1. This works; it is the classic method 2. ast; allows single pass to insert code to preserve values of non- redundant evaluahons & to replace the redundant evaluahons 3. Requires more analysis (VN), but yields more SEs ssume soluhon 2 OMP 512, Spring
28 lobal SE (replacement step) ompute a sta9c mapping from expressions to names oer analysis & before transformahon block b, e VIL(b), assign a global name to e Integer can be Hed to index of bit- vector set representahon During transformahon step ommon strategy: EvaluaHon of e insert copy name(e) e Insert copies that might be useful Reference to e replace e with name(e) Let dead code elim. sort them out Simplifies design & implementahon The major problem with this approach Inserts extraneous copies to preserve values that are of no later use t all definihons and uses of any e VIL(b), b e VIL(b) says nothing about whether or not e is ever computed again Those extra copies are dead and easy to remove The useful ones ooen coalesce away OMP 512, Spring
29 n side on Dead ode Elimina9on What does dead mean? Useless code result is never used Unreachable code code that cannot execute oth useless code & unreachable are ooen lumped together as dead To perform Dead ode Elimina9on Must have a global mechanism to recognize usefulness Must have a global mechanism to eliminate unneeded stores Must have a global mechanism to simplify control- flow predicates ll of these will come later in the course OMP 512, Spring
30 lobal SE So, we have a three step process 1. ompute VIL(b), block b 2. ssign unique global names to expressions in VIL(b) 3. Perform replacement with local value numbering Earlier in the lecture, the slide said ssume, without loss of generality, that we can compute available expressions for a procedure. Next lecture, we will make good on that assump;on OMP 512, Spring
Introduction to Optimization. CS434 Compiler Construction Joel Jones Department of Computer Science University of Alabama
Introduction to Optimization CS434 Compiler Construction Joel Jones Department of Computer Science University of Alabama Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
More informationLoop Invariant Code Mo0on
COMP 512 Rice University Spring 2015 Loop Invariant Code Mo0on A Simple Classical Approach Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University
More informationConstruc)on of Sta)c Single- Assignment Form
COMP 512 Rice University Spring 2015 Construc)on of Sta)c Single- Assignment Form Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University
More informationLocal Optimization: Value Numbering The Desert Island Optimization. Comp 412 COMP 412 FALL Chapter 8 in EaC2e. target code
COMP 412 FALL 2017 Local Optimization: Value Numbering The Desert Island Optimization Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon,
More informationOperator Strength Reduc1on
COMP 512 Rice University Spring 2015 Generali*es and the Cocke- Kennedy Algorithm Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University
More informationThe Big Picture. The Programming Assignment & A Taxonomy of Op6miza6ons. COMP 512 Rice University Spring 2015
COMP 512 Rice University Spring 2015 The Big Picture The Programming Assignment & A Taxonomy of Op6miza6ons Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp
More informationIntroduction to Optimization Local Value Numbering
COMP 506 Rice University Spring 2018 Introduction to Optimization Local Value Numbering source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights
More informationInstruction Scheduling Beyond Basic Blocks Extended Basic Blocks, Superblock Cloning, & Traces, with a quick introduction to Dominators.
Instruction Scheduling Beyond Basic Blocks Extended Basic Blocks, Superblock Cloning, & Traces, with a quick introduction to Dominators Comp 412 COMP 412 FALL 2016 source code IR Front End Optimizer Back
More informationMiddle End. Code Improvement (or Optimization) Analyzes IR and rewrites (or transforms) IR Primary goal is to reduce running time of the compiled code
Traditional Three-pass Compiler Source Code Front End IR Middle End IR Back End Machine code Errors Code Improvement (or Optimization) Analyzes IR and rewrites (or transforms) IR Primary goal is to reduce
More informationWelcome to COMP 512. COMP 512 Rice University Spring 2015
COMP 512 Rice University Spring 2015 Welcome to COMP 512 Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University have explicit permission
More informationData Structures and Algorithms in Compiler Optimization. Comp314 Lecture Dave Peixotto
Data Structures and Algorithms in Compiler Optimization Comp314 Lecture Dave Peixotto 1 What is a compiler Compilers translate between program representations Interpreters evaluate their input to produce
More informationTransla'on Out of SSA Form
COMP 506 Rice University Spring 2017 Transla'on Out of SSA Form Benoit Boissinot, Alain Darte, Benoit Dupont de Dinechin, Christophe Guillon, and Fabrice Rastello, Revisi;ng Out-of-SSA Transla;on for Correctness,
More informationDynamic Compila-on in Smalltalk- 80
COMP 512 Rice University Spring 2015 Dynamic Compila-on in Smalltalk- 80 The Deutsch- Schiffman Implementa4on L.P. Deutsch and A.M. Schiffman, Efficient ImplementaHon of the Smalltalk- 80 System, Conference
More informationInstruction Selection: Preliminaries. Comp 412
COMP 412 FALL 2017 Instruction Selection: Preliminaries Comp 412 source code Front End Optimizer Back End target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled
More informationLazy Code Motion. Comp 512 Spring 2011
Comp 512 Spring 2011 Lazy Code Motion Lazy Code Motion, J. Knoop, O. Ruthing, & B. Steffen, in Proceedings of the ACM SIGPLAN 92 Conference on Programming Language Design and Implementation, June 1992.
More informationCopyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit
Intermediate Representations Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies
More informationIntermediate Representations
COMP 506 Rice University Spring 2018 Intermediate Representations source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students
More informationCombining Optimizations: Sparse Conditional Constant Propagation
Comp 512 Spring 2011 Combining Optimizations: Sparse Conditional Constant Propagation Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University
More informationCompiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler
Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis Synthesis of output program (back-end) Intermediate Code Generation Optimization Before and after generating machine
More informationIntroduction to Optimization, Instruction Selection and Scheduling, and Register Allocation
Introduction to Optimization, Instruction Selection and Scheduling, and Register Allocation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Traditional Three-pass Compiler
More informationCode Shape Comp 412 COMP 412 FALL Chapters 4, 5, 6 & 7 in EaC2e. source code. IR IR target. code. Front End Optimizer Back End
COMP 412 FALL 2017 Code Shape Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at
More informationRegister Alloca.on via Graph Coloring
COMP 512 Rice University Spring 2015 Register Alloca.on via Graph Coloring Beyond Chai,n Briggs Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice
More informationCS293S Redundancy Removal. Yufei Ding
CS293S Redundancy Removal Yufei Ding Review of Last Class Consideration of optimization Sources of inefficiency Components of optimization Paradigms of optimization Redundancy Elimination Types of intermediate
More informationWhat If. Static Single Assignment Form. Phi Functions. What does φ(v i,v j ) Mean?
Static Single Assignment Form What If Many of the complexities of optimization and code generation arise from the fact that a given variable may be assigned to in many different places. Thus reaching definition
More informationLab 3, Tutorial 1 Comp 412
COMP 412 FALL 2018 Lab 3, Tutorial 1 Comp 412 source code IR IR Front End Optimizer Back End target code Copyright 2018, Keith D. Cooper, Linda Torczon & Zoran Budimlić, all rights reserved. Students enrolled
More informationLessons from Fi,een Years of Adap2ve Compila2on
COMP 512 Rice University Spring 2015 Lessons from Fi,een Years of Adap2ve Compila2on Keith Cooper, Tim Harvey, Devika Subramanian, and Linda Torczon, with Phil Schielke, Alex Grossman, Todd Waterman, and
More informationCS415 Compilers. Intermediate Represeation & Code Generation
CS415 Compilers Intermediate Represeation & Code Generation These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Review - Types of Intermediate Representations
More informationCalvin Lin The University of Texas at Austin
Loop Invariant Code Motion Last Time SSA Today Loop invariant code motion Reuse optimization Next Time More reuse optimization Common subexpression elimination Partial redundancy elimination February 23,
More informationIntermediate Representations
Most of the material in this lecture comes from Chapter 5 of EaC2 Intermediate Representations Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP
More informationCode Shape II Expressions & Assignment
Code Shape II Expressions & Assignment Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make
More informationParsing II Top-down parsing. Comp 412
COMP 412 FALL 2018 Parsing II Top-down parsing Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled
More informationThe View from 35,000 Feet
The View from 35,000 Feet This lecture is taken directly from the Engineering a Compiler web site with only minor adaptations for EECS 6083 at University of Cincinnati Copyright 2003, Keith D. Cooper,
More informationCalvin Lin The University of Texas at Austin
Loop Invariant Code Motion Last Time Loop invariant code motion Value numbering Today Finish value numbering More reuse optimization Common subession elimination Partial redundancy elimination Next Time
More informationThe Static Single Assignment Form:
The Static Single Assignment Form: Construction and Application to Program Optimizations - Part 3 Department of Computer Science Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design
More informationGlobal Register Allocation via Graph Coloring
Global Register Allocation via Graph Coloring Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission
More informationRegister Allocation. Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations
Register Allocation Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class
More informationCSE P 501 Compilers. SSA Hal Perkins Spring UW CSE P 501 Spring 2018 V-1
CSE P 0 Compilers SSA Hal Perkins Spring 0 UW CSE P 0 Spring 0 V- Agenda Overview of SSA IR Constructing SSA graphs Sample of SSA-based optimizations Converting back from SSA form Sources: Appel ch., also
More informationCS /534 Compiler Construction University of Massachusetts Lowell
CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 Lab Project 2: Parser and Type Checker for NOTHING Due: Sunday, November 14, 2004, 11:59 PM 1 Introduction
More informationTopic I (d): Static Single Assignment Form (SSA)
Topic I (d): Static Single Assignment Form (SSA) 621-10F/Topic-1d-SSA 1 Reading List Slides: Topic Ix Other readings as assigned in class 621-10F/Topic-1d-SSA 2 ABET Outcome Ability to apply knowledge
More informationImplementing Control Flow Constructs Comp 412
COMP 412 FALL 2018 Implementing Control Flow Constructs Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students
More informationFortran H and PL.8. Papers about Great Op.mizing Compilers. COMP 512 Rice University Spring 2015
Fortran H and PL.8 COMP 512 Rice University Spring 2015 Papers about Great Op.mizing Compilers R.S. Scarborough and H.G. Kolsky, Improved OpHmizaHon of FORTRAN Object Programs, IBM Journal of Research
More informationThe Software Stack: From Assembly Language to Machine Code
COMP 506 Rice University Spring 2018 The Software Stack: From Assembly Language to Machine Code source code IR Front End Optimizer Back End IR target code Somewhere Out Here Copyright 2018, Keith D. Cooper
More informationCS 406/534 Compiler Construction Instruction Scheduling
CS 406/534 Compiler Construction Instruction Scheduling Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy
More informationCS553 Lecture Profile-Guided Optimizations 3
Profile-Guided Optimizations Last time Instruction scheduling Register renaming alanced Load Scheduling Loop unrolling Software pipelining Today More instruction scheduling Profiling Trace scheduling CS553
More informationThe Processor Memory Hierarchy
Corrected COMP 506 Rice University Spring 2018 The Processor Memory Hierarchy source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved.
More informationCS 406/534 Compiler Construction Putting It All Together
CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy
More informationUSC 227 Office hours: 3-4 Monday and Wednesday CS553 Lecture 1 Introduction 4
CS553 Compiler Construction Instructor: URL: Michelle Strout mstrout@cs.colostate.edu USC 227 Office hours: 3-4 Monday and Wednesday http://www.cs.colostate.edu/~cs553 CS553 Lecture 1 Introduction 3 Plan
More informationRegister Allocation. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.
Register Allocation Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP at Rice. Copyright 00, Keith D. Cooper & Linda Torczon, all rights reserved.
More informationCompiler 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. # 10 Lecture No. # 16 Machine-Independent Optimizations Welcome to the
More informationCS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11
CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Spring 2015 1 Handling Overloaded Declarations Two approaches are popular: 1. Create a single symbol table
More informationCSE Section 10 - Dataflow and Single Static Assignment - Solutions
CSE 401 - Section 10 - Dataflow and Single Static Assignment - Solutions 1. Dataflow Review For each of the following optimizations, list the dataflow analysis that would be most directly applicable. You
More informationIntermediate representation
Intermediate representation Goals: encode knowledge about the program facilitate analysis facilitate retargeting facilitate optimization scanning parsing HIR semantic analysis HIR intermediate code gen.
More informationExample. Example. Constant Propagation in SSA
Example x=1 a=x x=2 b=x x=1 x==10 c=x x++ print x Original CFG x 1 =1 a=x 1 x 2 =2 x 3 =φ (x 1,x 2 ) b=x 3 x 4 =1 x 5 = φ(x 4,x 6 ) x 5 ==10 c=x 5 x 6 =x 5 +1 print x 5 CFG in SSA Form In SSA form computing
More informationGenerating Code for Assignment Statements back to work. Comp 412 COMP 412 FALL Chapters 4, 6 & 7 in EaC2e. source code. IR IR target.
COMP 412 FALL 2017 Generating Code for Assignment Statements back to work Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights
More informationSyntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412
Midterm Exam: Thursday October 18, 7PM Herzstein Amphitheater Syntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412 COMP 412 FALL 2018 source code IR Front End Optimizer Back End IR target
More informationA Bad Name. CS 2210: Optimization. Register Allocation. Optimization. Reaching Definitions. Dataflow Analyses 4/10/2013
A Bad Name Optimization is the process by which we turn a program into a better one, for some definition of better. CS 2210: Optimization This is impossible in the general case. For instance, a fully optimizing
More informationInstruction Selection, II Tree-pattern matching
Instruction Selection, II Tree-pattern matching Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 4 at Rice University have explicit permission
More informationInduction Variable Identification (cont)
Loop Invariant Code Motion Last Time Uses of SSA: reaching constants, dead-code elimination, induction variable identification Today Finish up induction variable identification Loop invariant code motion
More informationData Flow Analysis. Agenda CS738: Advanced Compiler Optimizations. 3-address Code Format. Assumptions
Agenda CS738: Advanced Compiler Optimizations Data Flow Analysis Amey Karkare karkare@cse.iitk.ac.in http://www.cse.iitk.ac.in/~karkare/cs738 Department of CSE, IIT Kanpur Static analysis and compile-time
More informationLocal Register Allocation (critical content for Lab 2) Comp 412
Updated After Tutorial COMP 412 FALL 2018 Local Register Allocation (critical content for Lab 2) Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda
More informationIntermediate Representations & Symbol Tables
Intermediate Representations & Symbol Tables Copyright 2014, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission
More informationWeek - 04 Lecture - 01 Merge Sort. (Refer Slide Time: 00:02)
Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 04 Lecture - 01 Merge Sort (Refer
More informationSta$c Single Assignment (SSA) Form
Sta$c Single Assignment (SSA) Form SSA form Sta$c single assignment form Intermediate representa$on of program in which every use of a variable is reached by exactly one defini$on Most programs do not
More informationLexical Analysis - An Introduction. Lecture 4 Spring 2005 Department of Computer Science University of Alabama Joel Jones
Lexical Analysis - An Introduction Lecture 4 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
More informationParsing. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.
Parsing Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students
More informationSyntax Analysis, VI Examples from LR Parsing. Comp 412
Midterm Exam: Thursday October 18, 7PM Herzstein Amphitheater Syntax Analysis, VI Examples from LR Parsing Comp 412 COMP 412 FALL 2018 source code IR IR target Front End Optimizer Back End code Copyright
More informationLanguages and Compiler Design II IR Code Optimization
Languages and Compiler Design II IR Code Optimization Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring 2010 rev.: 4/16/2010 PSU CS322 HM 1 Agenda IR Optimization
More informationTour of common optimizations
Tour of common optimizations Simple example foo(z) { x := 3 + 6; y := x 5 return z * y } Simple example foo(z) { x := 3 + 6; y := x 5; return z * y } x:=9; Applying Constant Folding Simple example foo(z)
More informationCompiler Optimization Intermediate Representation
Compiler Optimization Intermediate Representation Virendra Singh Associate Professor Computer Architecture and Dependable Systems Lab Department of Electrical Engineering Indian Institute of Technology
More informationIntermediate Representations Part II
Intermediate Representations Part II Types of Intermediate Representations Three major categories Structural Linear Hybrid Directed Acyclic Graph A directed acyclic graph (DAG) is an AST with a unique
More informationBuilding a Runnable Program and Code Improvement. Dario Marasco, Greg Klepic, Tess DiStefano
Building a Runnable Program and Code Improvement Dario Marasco, Greg Klepic, Tess DiStefano Building a Runnable Program Review Front end code Source code analysis Syntax tree Back end code Target code
More informationLecture 09X: C Func/on Pointers Concurrent and Mul/core Programming
Lecture 09X: C Func/on Pointers Concurrent and Mul/core Programming Department of Computer Science and Engineering Yonghong Yan yan@oakland.edu www.secs.oakland.edu/~yan 1 Pointer Variable Declara/ons
More informationGoals of Program Optimization (1 of 2)
Goals of Program Optimization (1 of 2) Goal: Improve program performance within some constraints Ask Three Key Questions for Every Optimization 1. Is it legal? 2. Is it profitable? 3. Is it compile-time
More informationMIT Introduction to Program Analysis and Optimization. Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology
MIT 6.035 Introduction to Program Analysis and Optimization Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Program Analysis Compile-time reasoning about run-time behavior
More informationBuilding a Parser Part III
COMP 506 Rice University Spring 2018 Building a Parser Part III With Practical Application To Lab One source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda
More informationSyntax Analysis, III Comp 412
COMP 412 FALL 2017 Syntax Analysis, III Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp
More informationProgram Optimizations using Data-Flow Analysis
Program Optimizations using Data-Flow Analysis!Last time! Lattice theoretic framework for data-flow analysis!today! Dead-code elimination! Common sub-expression elimination (CSE)! Copy propagation! Constant
More informationCS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Overview of the Course These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Critical Facts Welcome to CS415 Compilers Topics in the
More informationComputer Science 160 Translation of Programming Languages
Computer Science 160 Translation of Programming Languages Instructor: Christopher Kruegel Code Optimization Code Optimization What should we optimize? improve running time decrease space requirements decrease
More informationSyntax Analysis, III Comp 412
Updated algorithm for removal of indirect left recursion to match EaC3e (3/2018) COMP 412 FALL 2018 Midterm Exam: Thursday October 18, 7PM Herzstein Amphitheater Syntax Analysis, III Comp 412 source code
More informationPipelined Datapath. One register file is enough
ipelined path The goal of pipelining is to allow multiple instructions execute at the same time We may need to perform several operations in a cycle Increment the and add s at the same time. Fetch one
More informationLoops and Locality. with an introduc-on to the memory hierarchy. COMP 506 Rice University Spring target code. source code OpJmizer
COMP 506 Rice University Spring 2017 Loops and Locality with an introduc-on to the memory hierarchy source code Front End IR OpJmizer IR Back End target code Copyright 2017, Keith D. Cooper & Linda Torczon,
More informationSimple Machine Model. Lectures 14 & 15: Instruction Scheduling. Simple Execution Model. Simple Execution Model
Simple Machine Model Fall 005 Lectures & 5: Instruction Scheduling Instructions are executed in sequence Fetch, decode, execute, store results One instruction at a time For branch instructions, start fetching
More informationFlaco Lock Service. RESTful Distributed Locking Over HTTP. Jose Falcon Bryon Jacob
Flaco Lock Service RESTful Distributed Locking Over HTTP Jose Falcon Bryon Jacob 1 About Me Jose Falcon Graduate student @ University of Texas Expected graduahon: May 2010 Research interests: Programming
More informationComputing Inside The Parser Syntax-Directed Translation. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target.
COMP 412 FALL 2017 Computing Inside The Parser Syntax-Directed Translation Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights
More information: Advanced Compiler Design. 8.0 Instruc?on scheduling
6-80: Advanced Compiler Design 8.0 Instruc?on scheduling Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Overview 8. Instruc?on scheduling basics 8. Scheduling for ILP processors 8.
More informationOperational Semantics of Cool
Operational Semantics of Cool Lecture 23 Dr. Sean Peisert ECS 142 Spring 2009 1 Status Project 3 due on Friday Project 4 assigned on Friday. Due June 5, 11:55pm Office Hours this week Fri at 11am No Class
More informationAdministration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator
CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Administration Design reports due Friday Current demo schedule on web page send mail with preferred times if you haven
More informationUG3 Compiling Techniques Overview of the Course
UG3 Compiling Techniques Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission
More informationIntermediate Representations
Intermediate Representations Intermediate Representations (EaC Chaper 5) Source Code Front End IR Middle End IR Back End Target Code Front end - produces an intermediate representation (IR) Middle end
More informationSupplement to. Logic and Computer Design Fundamentals 4th Edition 1
Supplement to Logic and Computer esign Fundamentals 4th Edition MORE OPTIMIZTION Selected topics not covered in the fourth edition of Logic and Computer esign Fundamentals are provided here for optional
More informationComputer Science 146. Computer Architecture
Computer rchitecture Spring 2004 Harvard University Instructor: Prof. dbrooks@eecs.harvard.edu Lecture 11: Software Pipelining and Global Scheduling Lecture Outline Review of Loop Unrolling Software Pipelining
More informationQuery Processing & Optimization
Query Processing & Optimization 1 Roadmap of This Lecture Overview of query processing Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Introduction
More informationImage Transforms & Warps. 9/25/08 Comp 665 Image Transforms & Warps 1
Image Transforms & Warps 9/25/08 Comp 665 Image Transforms & Warps 1 Domain Transforms Previously, we have processed the range of signals Warping refers to processing the domain of a funchon, generally,
More informationJust-In-Time Compilers & Runtime Optimizers
COMP 412 FALL 2017 Just-In-Time Compilers & Runtime Optimizers Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved.
More informationAdvanced Compilers CMPSCI 710 Spring 2003 Dominators, etc.
Advanced ompilers MPSI 710 Spring 2003 ominators, etc. mery erger University of Massachusetts, Amherst ominators, etc. Last time Live variable analysis backwards problem onstant propagation algorithms
More informationReuse Optimization. LLVM Compiler Infrastructure. Local Value Numbering. Local Value Numbering (cont)
LLVM Compiler Infrastructure Source: LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation by Lattner and Adve Reuse Optimization Eliminate redundant operations in the dynamic execution
More informationSSA Construction. Daniel Grund & Sebastian Hack. CC Winter Term 09/10. Saarland University
SSA Construction Daniel Grund & Sebastian Hack Saarland University CC Winter Term 09/10 Outline Overview Intermediate Representations Why? How? IR Concepts Static Single Assignment Form Introduction Theory
More informationParsing III. CS434 Lecture 8 Spring 2005 Department of Computer Science University of Alabama Joel Jones
Parsing III (Top-down parsing: recursive descent & LL(1) ) (Bottom-up parsing) CS434 Lecture 8 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper,
More informationCS202 Compiler Construction
S202 ompiler onstruction pril 15, 2003 S 202-32 1 ssignment 11 (last programming assignment) Loop optimizations S 202-32 today 2 ssignment 11 Final (necessary) step in compilation! Implement register allocation
More information