Data-Flow Analysis (Chapter 11-12) Mooly Sagiv Make-up class 18/5 0900-12:00 Kaplun 324.

Slides:



Advertisements
Similar presentations
CSC 4181 Compiler Construction Code Generation & Optimization.
Advertisements

Optimizing Compilers for Modern Architectures Syllabus Allen and Kennedy, Preface Optimizing Compilers for Modern Architectures.
1 Optimization Optimization = transformation that improves the performance of the target code Optimization must not change the output must not cause errors.
Course Outline Traditional Static Program Analysis Software Testing
Lecture 11: Code Optimization CS 540 George Mason University.
Chapter 9 Code optimization Section 0 overview 1.Position of code optimizer 2.Purpose of code optimizer to get better efficiency –Run faster –Take less.
CMPUT Compiler Design and Optimization1 CMPUT680 - Winter 2006 Topic 5: Peep Hole Optimization José Nelson Amaral
Interprocedural Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday
19 Classic Examples of Local and Global Code Optimizations Local Constant folding Constant combining Strength reduction.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
SSA.
Chapter 10 Code Optimization. A main goal is to achieve a better performance Front End Code Gen Intermediate Code source Code target Code user Machine-
C Chuen-Liang Chen, NTUCS&IE / 321 OPTIMIZATION Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University.
1 Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
The Last Lecture Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University have explicit permission.
1 Data flow analysis Goal : collect information about how a procedure manipulates its data This information is used in various optimizations For example,
Introduction to Advanced Topics Chapter 1 Mooly Sagiv Schrierber
Early Global Program Optimizations Chapter Mooly Sagiv.
TM Pro64™: Performance Compilers For IA-64™ Jim Dehnert Principal Engineer 5 June 2000.
1 Copy Propagation What does it mean? Given an assignment x = y, replace later uses of x with uses of y, provided there are no intervening assignments.
1 CS 201 Compiler Construction Lecture 5 Code Optimizations: Copy Propagation & Elimination.
Compiler Optimizations for Memory Hierarchy Chapter 20 High Performance Compilers.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
9. Optimization Marcus Denker. 2 © Marcus Denker Optimization Roadmap  Introduction  Optimizations in the Back-end  The Optimizer  SSA Optimizations.
Code Generation for Basic Blocks Introduction Mooly Sagiv html:// Chapter
Introduction to Program Optimizations Chapter 11 Mooly Sagiv.
Case Studies of Compilers and Future Trends Chapter 21 Mooly Sagiv.
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
1 Copy Propagation What does it mean? – Given an assignment x = y, replace later uses of x with uses of y, provided there are no intervening assignments.
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
Compiler Optimization Overview
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
PSUCS322 HM 1 Languages and Compiler Design II IR Code Optimization Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU.
Procedure Optimizations and Interprocedural Analysis Chapter 15, 19 Mooly Sagiv.
Optimizing Compilers Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
24/06/2004Programming Language Design and Implementation 1 Optimizations in XSLT tokyo.ac.jp/schuko/XSLT-opt.ppt 24/June/04.
Optimization software for apeNEXT Max Lukyanov,  apeNEXT : a VLIW architecture  Optimization basics  Software optimizer for apeNEXT  Current.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
CSc 453 Final Code Generation Saumya Debray The University of Arizona Tucson.
Advanced Compiler Design Early Optimizations. Introduction Constant expression evaluation (constant folding)  dataflow independent Scalar replacement.
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
Synopsys University Courseware Copyright © 2012 Synopsys, Inc. All rights reserved. Compiler Optimization and Code Generation Lecture - 1 Developed By:
Cleaning up the CFG Eliminating useless nodes & edges C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon,
High-Level Transformations for Embedded Computing
Lexical analyzer Parser Semantic analyzer Intermediate-code generator Optimizer Code Generator Postpass optimizer String of characters String of tokens.
3/2/2016© Hal Perkins & UW CSES-1 CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2009.
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
Optimization Simone Campanoni
Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
Code Optimization Overview and Examples
High-level optimization Jakub Yaghob
Code Optimization.
Introduction to Advanced Topics Chapter 1 Text Book: Advanced compiler Design implementation By Steven S Muchnick (Elsevier)
Princeton University Spring 2016
Machine-Independent Optimization
Code Generation Part III
Optimizing Transformations Hal Perkins Autumn 2011
Topic 4: Flow Analysis Some slides come from Prof. J. N. Amaral
Optimizing Transformations Hal Perkins Winter 2008
Code Optimization Overview and Examples Control Flow Graph
Code Generation Part III
Fall Compiler Principles Lecture 10: Loop Optimizations
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
Lecture 19: Code Optimisation
CSc 453 Final Code Generation
Code Optimization.
Presentation transcript:

Data-Flow Analysis (Chapter 11-12) Mooly Sagiv Make-up class 18/ :00 Kaplun 324

Data-Flow Analysis(Kildall 1973) Input: –A control flow graph Nodes – Basic blocks Edges- Jumps, Branches –Lattice L= –An element Init  L (The value at procedure entry) –The effect of every block F B : L  L Output: An upper approximation to the join over all paths JOP[B] =  P  Path(B) F Bn ...  F B2  F B1 (Init) Method –Find the least solution to: In[Entry] = Init In[B] =  B’  Pred(B) Out[B’] Out[B] = F B (In[B])

Tentative Plan Order of Optimizations Early Program Optimizations (Friday) Redundancy Elimination and Loop Optimizations (May 24) Procedures (May 31)

Order of Optimizations and Repetitions Transformations are order-dependent No “Optimal order” May need to repeat certain transformations

Textbook Order Scalar replacement of array references Data-cache optimizations A HIR Global value numbering … C MIR|LIR Procedure integration … B HIR|MIR In-line expansion … D LIR Interprocedural register allocation … E link-time constant-folding simplifications

Procedure integration Tail-call elimination Scalar replacement of aggregates Sparse conditional constant propagation Interprocedural constant propagation Procedure specialization and cloning Sparse conditional constant propagation Early High Level Optimizations (B) HIR|MIR constant-folding simplifications

MIR|LIR(C) constant-folding simplifications Global value numbering Local and global copy propagation Sparse conditional constant propagation Dead code elimination Common Subexpression Elimination Loop invariant code motion Partial redundency Elimination Dead code elimination code hoisting induction variable strength reduction linear function test replacement induction variable removal bound checking elimination, control flow optimizations

LIR(D) constant-folding simplifications Inline expansion Leaf-routine optimizations Shrink wrapping Machine idioms Tail merging Branch optimization and conditional moves Dead code elimination Software pipelining, … Instruction Scheduling 1 Register allocation Instruction Scheduling 2 Intraprocedural I-cache optimizations Instruction prefetching Data prefertching Branch predication

Link-time optimizations(E) Interprocedural register allocation Aggregation global references Interprcudural I-cache optimizations

Scalar replacement of array references Data-cache optimizations Procedure integration Tail-call elimination Scalar replacement of aggregates Sparse constant propagation Interprocedural constant propagation Procedure specialization and cloning Sparse conditional constant propagation Global value numbering Local and global copy propagation Sparse conditional constant propagation Dead code elimination Common Subexpression Elimination Loop invariant code motion Partial redundency Elimination Inline expansion Leaf-routine optimizations Instruction Scheduling 1 Register allocation Instruction Scheduling 2 Intraprocedural I-cache optimizations Instruction prefetching Data prefertching Branch predication Interprocedural register allocation Interprocedural I-cache optimization