Transla'on Out of SSA Form
|
|
- Erica Brooks
- 6 years ago
- Views:
Transcription
1 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, Code Quality, and Efficiency, CGO Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University have explicit permission to make copies of these materials for their personal use. Faculty from other educaional insituions may use these materials for nonprofit educaional purposes, provided this copyright noice is preserved CitaIon numbers refer to entries in the EaC2e bibliography.
2 SSA Deconstruc;on At some point, we need executable code Do machines implement ϕ-operaions? Need to fix up the flow of values Original idea [CFRWZ, 110] Replace ϕ-funcion with copies in predecessor blocks Simple algorithm Works in most cases Adds lots of copies Most of them coalesce away Copy-coalescing is well understood See, for example, Chai0n-Briggs GCRA [75,56] X 17 ϕ (x 10,x 11 )... x 17 X 17 x 10 X 17 x x 17 COMP 506, Rice University 2
3 Transla;on Out of SSA Form Two classic problems arise in SSA deconstruc;on Lost-copy problem Swap problem In each case, simple copy inserion produces incorrect code Cri;cal Observa;on Both problems are caused by transformaions that rewrite the code and move definiions and uses Some of the complicaion arises from the shi_ between the parallel semanics of the Φ-funcIons and the sequenial semanics of copy These problems were idenified by Cliff Click and first published by Briggs et al. in 1997 [50]. They presented ad-hoc ways of solving the problems. (Click is not an author; he found the problems.) This lecture is based on the work of Boissinot et al. and presents a more systemaic approach to solving the problems inherent in translaion out of SSA form. See RevisiIng Out-of-SSA TranslaIon for Correctness, Code Quality, and Efficiency, by Benoit Boissinot, Alain Darte, Benoit Dupont de Dinechin, Christophe Guillon, and COMP Fabrice 506, Rastello Rice University in CGO
4 TRANSLATION OUT OF SSA FORM The Lost Copy Problem i 1 In opimizaion, a cri;cal edge in a control-flow graph is one that runs from a node with muliple successors to node with muliple predecessors. In out-of-ssa transla;on, cri;cal edges create serious problems for copy inserion. i 1 i 0 cri;cal edge y i i i + 1 i 1 Φ(i 0,i 2 ) y 0 i 1 i 1 Φ(i 0,i 2 ) i 1 i 2 d y + z 0 y 0 + Original code In SSA form With copies folded Copies naïvely inserted Copy folding is a simple transformaion that creates the problem. Other transformaions can have the same effect. The assignment to z now receives the wrong value. To fix this problem, the compiler either needs to create a temporary name to hold the penulimate value of i, or to insert the copy in the loop-closing branch. COMP 506, Rice University 4 *
5 TranslaIon Out of SSA Form Copy folding can only produce this code because of the parallel seman;cs of Φ-func;ons The Swap Problem x y x 1 x 0 y 1 y 0 Ignored the parallel seman;cs of the Φ func;ons t x x y y t x 1 Φ(x 0,x 2 ) y 1 Φ(y 0,y 2 ) t 0 x 1 x 2 y 1 y 2 t 0 x 1 Φ(x 0,y 1 ) y 1 Φ(y 0,x 1 ) x 1 y 1 y 1 x Original code In SSA Form Copies folded Copies naïvely inserted Code is incorrect This problem arises when a Φ-funcIon argument is defined by a Φ-funcIon in the same block. To generate correct code, the compiler will need to insert one or more additonal copy operaions and temporary names. * COMP 506, Rice University 5
6 Transla;on Out of SSA Form The Big Picture Swap problem & lost-copy problem arise from messing with Φ-funcIon parameters Renaming Φ-funcIon parameters, moving their definiions, Underlying issue is the parallel semanics of Φ-funcIon evaluaion One way to simplify out-of-ssa translaion is to separate the parallelism from the Φ-funcIons and tackle it directly Convert to a form of SSA where eliminaing the subscripts produces correct code We call that form ConvenIonal SSA or CSSA COMP 506, Rice University 6
7 Transla;on Out of SSA Form The Big Picture Insert parallel copies to convert SSA to convenional SSA In CSSA, we can just drop the subscripts on SSA name Introduces a new set of names Rename out of CSSA by replacing introduced names Eliminate Φ funcions as in original paper Insert copies at end of the predecessor blocks SequenIalize parallel copies (may introduce new temporaries) Aggressive copy coalescing to remove copies Can coalesce copies before renaming or a_er we are done Coalescing parallel copies requires some care May be easier, and clearer, to coalesce a_er sequenializaion Moves the issues created by parallel Φ funcion semanics back into pred. blocks (in parallel copies). e.g., Budimlic et. al. PLDI 2002, or unrestricted coalescing [75,56] Sketch of ideas from Revisi0ng Out-of-SSA Transla0on for Correctness, Efficiency, and Speed, Boissinot, Darte, de Dinechin, Guillon, and Rastello, Proceedings of CGO COMP 506, Rice University 7
8 The Individual Steps Convert SSA to CSSA For a ϕ-funcion a 0 ϕ(a 1,a 2,, a n ) : 1. Insert a parallel copy a 1 a 1 at the end of the block corresponding to a 1 2. Replace a 0 ϕ(a 1,a 2,, a n ) with a 0 ϕ(a 1,a 2,, a n ) 3. Insert a parallel copy a 0 a 0 a_er the ϕ-funcion Rename Out Of CSSA primed name, i j, drop the subscripts and replace each i with a new name Remove Φ Func;ons Replace Φ-funcIons with copies in predecessor blocks as in CFRWZ paper Use parallel copies for good measure Sequen;alize The Parallel Copies Build a dependence graph and break cycles with a new name COMP Copies 506, inserted Rice University for different Φ-funcIons in the same block form a parallel copy group. 8
9 Sequen;alizing Parallel Copies A parallel copy group forms a graph a d a 4 b; b 4 c; c 4 a; d 4 a Parallel copies b c Corresponding graph Graph is either a tree or a cycle Schedule a tree, bopom up from the leaves Must break each cycle with an extra copy May require a new name Other copies may avoid the extra name If possible, break on the value preserved in a non-cycle copy d a a b b c c d Serialized copies Subscripts on the copies indicate parallel copy group membership. COMP 506, Rice University 9
10 Reminder from earlier slide TRANSLATION OUT OF SSA FORM The Lost Copy Problem i 1 i 1 i 0 y i i i + 1 i 1 Φ(i 0,i 2 ) y 0 i 1 i 1 Φ(i 0,i 2 ) i 1 i 2 d y + z 0 y 0 + Original code In SSA form With copies folded Copies naïvely inserted Copy folding is a simple transformaion that creates the problem. Other transformaions can have the same effect. The assignment to z now receives the wrong value. To fix this problem, the compiler needs to create a temporary name to hold the penulimate value of i. COMP 506, Rice University 10
11 TRANSLATION OUT OF SSA FORM The Lost Copy Problem via CSSA i 0 i o x i o i 1 y i i i + 1 i 1 Φ(i 0,i 2 ) i 1 Φ(i 0,i 2 ) i 1 i 1 i 2 i 2 x Φ(x,x) i 1 x x i 2 z y + Original code In SSA with copies folded Insert parallel copies to create CSSA Rename out of CSSA With only one Φ, parallel is a singleton. Each use of i replaced with x. Use of i 1 to compute z 0 is correct. COMP 506, Rice University 11
12 TRANSLATION OUT OF SSA FORM The Lost Copy Problem via CSSA x i o x i o x x x 1 x Φ(x,x) i 1 x x i 2 x Φ(x,x) i 1 x x i 2 x x i 1 x x i i 1 y i i i + 1 z 0 y + From previous slide Replace Φ s with copies A]er coalescing The original code Copies look rather stupid because it is a simple case, but it is correct. COMP 506, Rice University 12
13 Reminder from earlier slide TranslaIon Out of SSA Form The Swap Problem x y x 1 x 0 y 1 y 0 t x x y y t x 1 Φ(x 0,x 2 ) y 1 Φ(y 0,y 2 ) t 0 x 1 x 2 y 1 y 2 t 0 x 1 Φ(x 0,y 1 ) y 1 Φ(y 0,x 1 ) x 1 y 1 y 1 x 1 Original code In SSA Form Copies folded Copies naïvely inserted Code is incorrect This problem arises when a Φ-funcIon argument is defined by a Φ-funcIon in the same block. To generate correct code, the compiler will need to insert one or more additonal copy operaions and temporary names. COMP 506, Rice University 13
14 TRANSLATION OUT OF SSA FORM The Swap Problem x 0 1 x 0 y 0 1 y 0 a 1 x 0 b 1 y 0 a 1 x 0 b 1 y 0 a 4 a b 4 b x 1 Φ(x 0,y 1 ) y 1 Φ(y 0,x 1 ) x 1 Φ(x 0,y 1 ) y 1 Φ(y 0,x 1 ) x 1 2 x 1 y 1 2 y 1 x 1 3 x 1 y 1 3 y 1 a Φ(a,b) b Φ(b,a) x 1 2 a y 1 2 b a 3 x 1 b 3 y 1 x 1 2 a y 1 2 b a 3 x 1 b 3 y 1 a 5 b b 5 a Star;ng Point (code in SSA form) Convert to CSSA Rename primed variables Eliminate Φ func;ons (used parallel copies) COMP 506, Rice University Subscript on indicates a parallel copy group 14
15 TRANSLATION OUT OF SSA FORM The Swap Problem a x 0 a 1 x 0 b 1 y 0 a 4 a b 4 b b a b y 0 a b a x 0 b y 0 a a b b x 1 a x 1 2 a y 1 2 b a 3 x 1 b 3 y 1 a 5 b b 5 a y 1 a b b x 1 y 1 x 1 a y 1 b a x 1 b y 1 a 5 b b 5 a Result from previous slide Parallel copy groups 1, 2, 3, & 4 have acyclic dependence graphs. They can be scheduled in either order. Groups 1, 2, 3, & 4 sequen;alized COMP 506, Rice University 15
16 TRANSLATION OUT OF SSA FORM The Swap Problem a x 0 b y 0 a a b b These copies coalesce away These copies are useless a x 0 b y 0 a a b b x 1 a y 1 b a x 1 b y 1 a 5 b b 5 a a b Cyclic dependence graph for parallel copy group 5 These copies are LIVE These copies are useless x 1 a y 1 b a x 1 b y 1 t a a b b t Must break this cycle with an extra copy & a new name. Groups 1, 2, 3, & 4 sequen;alized All copies are now sequen;al COMP 506, Rice University 16
17 Transla;on Out of SSA Form To recap, the algorithm is Insert parallel copies to convert SSA to convenional SSA In CSSA, we can just drop the subscripts on SSA name Introduces a new set of names Rename out of CSSA by replacing introduced names Eliminate Φ funcions by insering parallel copies in prior blocks May look redundant, but is necessary to handle the swap problem SequenIalize parallel copies (may introduce new temporaries) Aggressive copy coalescing to remove copies Can coalesce copies before renaming or a_er we are done Coalescing parallel copies requires some care May be easier, and clearer, to coalesce a_er sequenializaion e.g., ChaiIn-Briggs unrestricted coalescing or Budimlic et. al. PLDI COMP 506, Rice University 17
18 Using SSA Form in a Compiler Need to translate source or IR into SSA form Algorithm from earlier lecture [110,50] IR needs to represent both Φ-funcIons and Φ-argument to CFG edge correspondance Working with SSA Form The SSA name space makes some kinds of transformaions harder Code moion past Φ-funcIons is problemaic SSA provides a useful sparse representaion that can lead to efficiency Wegman-Zadeck SCP and SCCP as examples [347] Need to translate out of SSA form Algorithms from this lecture LLVM comes out of SSA in code generator (selec0on, alloca0on, scheduling) COMP 506, Rice University 18
Towards an SSA based compiler back-end: some interesting properties of SSA and its extensions
Towards an SSA based compiler back-end: some interesting properties of SSA and its extensions Benoit Boissinot Équipe Compsys Laboratoire de l Informatique du Parallélisme (LIP) École normale supérieure
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 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 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 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 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 informationStatic single assignment
Static single assignment Control-flow graph Loop-nesting forest Static single assignment SSA with dominance property Unique definition for each variable. Each definition dominates its uses. Static single
More informationIntroduction 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 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 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 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 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 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 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 informationRevisiting Out-of-SSA Translation for Correctness, Code Quality, and Efficiency
Revisiting Out-of-SSA Translation for Correctness, Code Quality, and Efficiency Benoit Boissinot, Alain Darte, Fabrice Rastello, Benoît Dupont de Dinechin, Christophe Guillon To cite this version: Benoit
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 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 information6. Intermediate Representation
6. Intermediate Representation Oscar Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes. http://www.cs.ucla.edu/~palsberg/
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 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 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 informationA Sparse Algorithm for Predicated Global Value Numbering
Sparse Predicated Global Value Numbering A Sparse Algorithm for Predicated Global Value Numbering Karthik Gargi Hewlett-Packard India Software Operation PLDI 02 Monday 17 June 2002 1. Introduction 2. Brute
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 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 informationCS153: Compilers Lecture 23: Static Single Assignment Form
CS153: Compilers Lecture 23: Static Single Assignment Form Stephen Chong https://www.seas.harvard.edu/courses/cs153 Pre-class Puzzle Suppose we want to compute an analysis over CFGs. We have two possible
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 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 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 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 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 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 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 information6. Intermediate Representation!
6. Intermediate Representation! Prof. O. Nierstrasz! Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes.! http://www.cs.ucla.edu/~palsberg/!
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 informationCS415 Compilers Register Allocation. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Register Allocation These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Review: The Back End IR Instruction Selection IR Register
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 informationOverview Of Op*miza*on, 2
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
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 informationRuntime Support for OOLs Object Records, Code Vectors, Inheritance Comp 412
COMP 412 FALL 2017 Runtime Support for OOLs Object Records, Code Vectors, Inheritance Comp 412 source IR Front End Optimizer Back End IR target Copyright 2017, Keith D. Cooper & Linda Torczon, all rights
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 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 informationNaming in OOLs and Storage Layout Comp 412
COMP 412 FALL 2018 Naming in OOLs and Storage Layout Comp 412 source IR IR target Front End Optimizer Back End Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in
More informationIntroduction to Machine-Independent Optimizations - 6
Introduction to Machine-Independent Optimizations - 6 Machine-Independent Optimization Algorithms Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course
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 information8. Static Single Assignment Form. Marcus Denker
8. Static Single Assignment Form Marcus Denker Roadmap > Static Single Assignment Form (SSA) > Converting to SSA Form > Examples > Transforming out of SSA 2 Static Single Assignment Form > Goal: simplify
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 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 informationRuntime Support for Algol-Like Languages Comp 412
COMP 412 FALL 2018 Runtime Support for Algol-Like Languages 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 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 informationArrays and Functions
COMP 506 Rice University Spring 2018 Arrays and Functions source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled
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 informationParsing II Top-down parsing. Comp 412
COMP 412 FALL 2017 Parsing II Top-down parsing Comp 412 source code IR Front End OpMmizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled
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 informationECE 5775 High-Level Digital Design Automation Fall More CFG Static Single Assignment
ECE 5775 High-Level Digital Design Automation Fall 2018 More CFG Static Single Assignment Announcements HW 1 due next Monday (9/17) Lab 2 will be released tonight (due 9/24) Instructor OH cancelled this
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 informationCompiler Construction 2009/2010 SSA Static Single Assignment Form
Compiler Construction 2009/2010 SSA Static Single Assignment Form Peter Thiemann March 15, 2010 Outline 1 Static Single-Assignment Form 2 Converting to SSA Form 3 Optimization Algorithms Using SSA 4 Dependencies
More informationHandling Assignment Comp 412
COMP 412 FALL 2018 Handling Assignment Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp
More informationStatic Single Assignment (SSA) Form
Static Single Assignment (SSA) Form A sparse program representation for data-flow. CSL862 SSA form 1 Computing Static Single Assignment (SSA) Form Overview: What is SSA? Advantages of SSA over use-def
More informationThe ILOC Virtual Machine (Lab 1 Background Material) Comp 412
COMP 12 FALL 20 The ILOC Virtual Machine (Lab 1 Background Material) Comp 12 source code IR Front End OpMmizer Back End IR target code Copyright 20, Keith D. Cooper & Linda Torczon, all rights reserved.
More informationProcedure and Function Calls, Part II. Comp 412 COMP 412 FALL Chapter 6 in EaC2e. target code. source code Front End Optimizer Back End
COMP 412 FALL 2017 Procedure and Function Calls, Part II Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students
More informationCompiler Design. Register Allocation. Hwansoo Han
Compiler Design Register Allocation Hwansoo Han Big Picture of Code Generation Register allocation Decides which values will reside in registers Changes the storage mapping Concerns about placement of
More informationLexical Analysis. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.
Lexical Analysis 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.
More informationComputing Inside The Parser Syntax-Directed Translation. Comp 412
COMP 412 FALL 2018 Computing Inside The Parser Syntax-Directed Translation Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights
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 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 informationIntroduction to Parsing. Comp 412
COMP 412 FALL 2010 Introduction to Parsing Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make
More informationData Flow Analysis and Computation of SSA
Compiler Design 1 Data Flow Analysis and Computation of SSA Compiler Design 2 Definitions A basic block is the longest sequence of three-address codes with the following properties. The control flows to
More informationFast Copy Coalescing and Live-Range Identification
Fast Copy Coalescing and Live-Range Identification Zoran Budimlić, Keith D. Cooper, Timothy J. Harvey, Ken Kennedy, Timothy S. Oberg, and Steven W. Reeves Department of Computer Science Rice University,
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 informationThe Development of Static Single Assignment Form
The Development of Static Single Assignment Form Kenneth Zadeck NaturalBridge, Inc. zadeck@naturalbridge.com Ken's Graduate Optimization Seminar We learned: 1.what kinds of problems could be addressed
More informationComputing Static Single Assignment (SSA) Form. Control Flow Analysis. Overview. Last Time. Constant propagation Dominator relationships
Control Flow Analysis Last Time Constant propagation Dominator relationships Today Static Single Assignment (SSA) - a sparse program representation for data flow Dominance Frontier Computing Static Single
More informationCode Placement, Code Motion
Code Placement, Code Motion Compiler Construction Course Winter Term 2009/2010 saarland university computer science 2 Why? Loop-invariant code motion Global value numbering destroys block membership Remove
More informationGrammars. CS434 Lecture 15 Spring 2005 Department of Computer Science University of Alabama Joel Jones
Grammars CS434 Lecture 5 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled
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 informationECE 5775 (Fall 17) High-Level Digital Design Automation. Static Single Assignment
ECE 5775 (Fall 17) High-Level Digital Design Automation Static Single Assignment Announcements HW 1 released (due Friday) Student-led discussions on Tuesday 9/26 Sign up on Piazza: 3 students / group Meet
More informationC-SSAPRE: Eliminating redundancy over copies
C-SSAPRE: Eliminating redundancy over copies Tom Murphy VII, Brendan McMahan 7 May 2003 1 Introduction Partial Redundancy Elimination (PRE) is an optimization that prevents, where possible, the re-computation
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 informationLecture 21 CIS 341: COMPILERS
Lecture 21 CIS 341: COMPILERS Announcements HW6: Analysis & Optimizations Alias analysis, constant propagation, dead code elimination, register allocation Available Soon Due: Wednesday, April 25 th Zdancewic
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 informationSyntax Analysis, VII One more LR(1) example, plus some more stuff. Comp 412 COMP 412 FALL Chapter 3 in EaC2e. target code.
COMP 412 FALL 2017 Syntax Analysis, VII One more LR(1) example, plus some more stuff Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon,
More informationOptimizer. Defining and preserving the meaning of the program
Where are we? Well understood Engineering Source Code Front End IR Optimizer IR Back End Machine code Errors The latter half of a compiler contains more open problems, more challenges, and more gray areas
More informationCS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Procedure Abstractions These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Where are we? Well understood Engineering Source Code
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 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 informationThe So'ware Stack: From Assembly Language to Machine Code
Taken from COMP 506 Rice University Spring 2017 The So'ware Stack: From Assembly Language to Machine Code source code IR Front End OpJmizer Back End IR target code Somewhere Out Here Copyright 2017, Keith
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 informationComputing Inside The Parser Syntax-Directed Translation, II. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target.
COMP 412 FALL 20167 Computing Inside The Parser Syntax-Directed Translation, II Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all
More informationMechanized Verification of SSA-based Compilers Techniques
Mechanized Verification of SSA-based Compilers Techniques Delphine Demange - U. Rennes 1 / IRISA / Inria Rennes Joint work with G. Barthe, S. Blazy, Y. Fernandez de Retana, D. Pichardie, L. Stefanesco
More informationMechanizing Conventional SSA for a Verified Destruction with Coalescing
Mechanizing Conventional SSA for a Verified Destruction with Coalescing Delphine Demange University of Rennes 1 / IRISA / Inria, France delphine.demange@irisa.fr Yon Fernandez de Retana University of Rennes
More informationSustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)
COMP 412 FALL 2017 Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java) Copyright 2017, Keith D. Cooper & Zoran Budimlić, all rights reserved. Students enrolled in Comp 412 at Rice
More informationLecture 3 Local Optimizations, Intro to SSA
Lecture 3 Local Optimizations, Intro to SSA I. Basic blocks & Flow graphs II. Abstraction 1: DAG III. Abstraction 2: Value numbering IV. Intro to SSA ALSU 8.4-8.5, 6.2.4 Phillip B. Gibbons 15-745: Local
More informationCode Merge. Flow Analysis. bookkeeping
Historic Compilers 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 of these materials
More informationLecture 23 CIS 341: COMPILERS
Lecture 23 CIS 341: COMPILERS Announcements HW6: Analysis & Optimizations Alias analysis, constant propagation, dead code elimination, register allocation Due: Wednesday, April 25 th Zdancewic CIS 341:
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 informationIntermediate Representation (IR)
Intermediate Representation (IR) Components and Design Goals for an IR IR encodes all knowledge the compiler has derived about source program. Simple compiler structure source code More typical compiler
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 informationRegister Allocation 3/16/11. What a Smart Allocator Needs to Do. Global Register Allocation. Global Register Allocation. Outline.
What a Smart Allocator Needs to Do Register Allocation Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations Determine ranges for each variable can benefit from using
More informationPreference-Guided Register Assignment
Preference-Guided Register Assignment Matthias Braun 1, Christoph Mallon 2, and Sebastian Hack 2 1 Karlsruhe Institute of Technology matthias.braun@kit.edu 2 Computer Science Department Saarland University
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 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 information