The Last Lecture Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University have explicit permission.

Slides:



Advertisements
Similar presentations
Code Optimization, Part II Regional Techniques Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp.
Advertisements

School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
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.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Code Motion of Control Structures From the paper by Cytron, Lowry, and Zadeck, COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda.
SSA-Based Constant Propagation, SCP, SCCP, & the Issue of Combining Optimizations 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon,
Partial Redundancy Elimination & Lazy Code Motion
Lazy Code Motion C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled.
Interprocedural Optimization — a much older version of the lecture — Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled.
Loop Invariant Code Motion — classical approaches — 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students.
Introduction to Code Optimization Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
Intermediate Representations Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
TM Pro64™: Performance Compilers For IA-64™ Jim Dehnert Principal Engineer 5 June 2000.
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
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.
9. Optimization Marcus Denker. 2 © Marcus Denker Optimization Roadmap  Introduction  Optimizations in the Back-end  The Optimizer  SSA Optimizations.
Introduction to Program Optimizations Chapter 11 Mooly Sagiv.
Data-Flow Analysis (Chapter 11-12) Mooly Sagiv Make-up class 18/ :00 Kaplun 324.
Introduction to Optimization Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Introduction to Code Generation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Instruction Scheduling II: Beyond Basic Blocks Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp.
Dynamic Optimization as typified by the Dynamo System See “Dynamo: A Transparent Dynamic Optimization System”, V. Bala, E. Duesterwald, and S. Banerjia,
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Global Common Subexpression Elimination with Data-flow Analysis Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students.
Code Optimization, Part III Global Methods Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Introduction to Optimization, II Value Numbering & Larger Scopes Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students.
First Principles (with examples from value numbering) C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon,
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
Using SSA Dead Code Elimination & Constant Propagation C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon,
Order from Chaos — the big picture — 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled.
Order from Chaos — the big picture — C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon, all rights reserved.
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
Building SSA Form, III 1COMP 512, Rice University This lecture presents the problems inherent in out- of-SSA translation and some ways to solve them. Copyright.
Replication & Consolidation — a grab bag of transformations — 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Synopsys University Courseware Copyright © 2012 Synopsys, Inc. All rights reserved. Compiler Optimization and Code Generation Lecture - 1 Developed By:
Global Redundancy Elimination: Computing Available Expressions Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled.
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.
Algebraic Reassociation of Expressions Briggs & Cooper, “Effective Partial Redundancy Elimination,” Proceedings of the ACM SIGPLAN 1994 Conference on Programming.
Introduction to Code Generation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
Improving Locality through Loop Transformations Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at.
Terminology, Principles, and Concerns, III With examples from DOM (Ch 9) and DVNT (Ch 10) Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved.
Dead Code Elimination This lecture presents the algorithm Dead from EaC2e, Chapter 10. That algorithm derives, in turn, from Rob Shillner’s unpublished.
Boolean & Relational Values Control-flow Constructs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
Lessons from the PL.8 Compiler “An Overview of the PL.8 Compiler”, Marc Auslander & Martin Hopkins, Proceedings of the SIGPLAN 82 Symposium on Compiler.
Terminology, Principles, and Concerns, II With examples from superlocal value numbering (Ch 8 in EaC2e) Copyright 2011, Keith D. Cooper & Linda Torczon,
Cleaning up the CFG Eliminating useless nodes & edges This lecture describes the algorithm Clean, presented in Chapter 10 of EaC2e. The algorithm is due.
3/2/2016© Hal Perkins & UW CSES-1 CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2009.
Eliminating Array Bounds Checks — and related problems — 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved.
Code Optimization Overview and Examples
Introduction to Optimization
Finding Global Redundancies with Hopcroft’s DFA Minimization Algorithm
Introduction to Optimization
Intermediate Representations
Introduction to Code Generation
Optimizing Transformations Hal Perkins Autumn 2011
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit.
Intermediate Representations
Optimizing Transformations Hal Perkins Winter 2008
Optimization through Redundancy Elimination: Value Numbering at Different Scopes COMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith.
The Last Lecture COMP 512 Rice University Houston, Texas Fall 2003
Copyright 2003, Keith D. Cooper & Linda Torczon, all rights reserved.
Introduction to Optimization
Algebraic Reassociation of Expressions COMP 512 Rice University Houston, Texas Fall 2003 P. Briggs & K.D. Cooper, “Effective Partial Redundancy Elimination,”
Lecture 19: Code Optimisation
The Partitioning Algorithm for Detecting Congruent Expressions COMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper.
Presentation transcript:

The Last Lecture Copyright 2011, 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 educational institutions may use these materials for nonprofit educational purposes, provided this copyright notice is preserved. Comp 512 Spring 2011

COMP 512, Fall Putting It All Together Key questions that a compiler writer must answer What should the optimizer & back end do? How should the compiler represent the program? Broad answers Figure out what the real problems are Learn everything you can about the target machine Attack each problem with a specific plan Separate concerns as long as possible

COMP 512, Fall Lessons Experience is a tough teacher Understand what the code looks like  On input to the compiler and on output from the compiler  Hard to see problems in large procedures A good compiler need not do everything  Study the code & figure out what’s needed  Do those things well & do them thoroughly Hand simulation before implementation pays off  Avoid implementing things that solve no problem Find the right level of abstraction for each optimization  Constant propagation can be done at source level  Redundancy elimination should be done at a low-level

COMP 512, Fall Lessons Experience is a tough teacher Intermediate representations are important  Determines level of exposed detail  Every pass traverses it, so efficient manipulation is critical Code shape and name spaces are important  Determine opportunities & size of data structures  Has large impact on effectiveness of algorithms Compile-time space counts  Limits size of procedures that can be compiled  Compiler touches all that space  More complex analyses take lots of space

COMP 512, Fall Lessons Experience is a tough teacher Separation of concerns is vital to progress  Resource constraints from rearrangement  Allocation from optimization  Parsing from code generation Separation of concerns interferes with optimization  Allocation & scheduling  Evaluation order & redundancy elimination  Code shape decisions affect later passes { Loop shape, case stmts. Annotations ( ILOC tags)

COMP 512, Fall Recap of Material COMP 512 had material in three distinct tracks Experience papers on influential compilers Static analysis of code Transformations intended to improve the code

COMP 512, Fall Recap of Material Experience papers 1. Fortran H Compiler 2. PL.8 Compiler 3. Deutsch-Schiffman Smalltalk-80 System 4. Dynamo 5. Our own work with adaptive compilation

COMP 512, Fall Recap of Material Static Analysis of Code Global CSE using A VAIL Iterative data-flow solvers Proliferation of data-flow problems Def-Use chains as a response to proliferation Building and using SSA form Wegman-Zadeck Constant Propagation ( SSCP, SCCP ) Interprocedural data-flow analysis

COMP 512, Fall Recap of Material Transformations intended to improve the code Value numbering ( LVN, SVN, DVNT ) Global CSE with AVAIL ( GCSE ) Lazy Code Motion ( LCM ) Alpern-Wegman-Zadeck partitioning algorithm ( AWZ ) Useless code elimination ( DEAD ) Control-flow simplification ( CLEAN ) Unreachable code elimination ( reachability, SCCP ) Constant propagation ( SSCP, SCCP ) Algebraic reassociation of expressions Operator strength reduction ( OSR ) Optimizing for energy consumption Eliminating array bounds checks

COMP 512, Fall Transformations intended to improve the code (continued ) 13. Inline substitution 14. Procedure cloning 15. Block cloning (including superblock cloning, fall-through branch optimization, & Wienskoksi’s scheme for software pipelining) 16. Loop unrolling 17. Loop unswitching 18. Loop fusion 19. Loop fission (distribution) 20. Loop interchange & permutation 21. Strip mining and tiling (or blocking) 22. Unroll and Jam 23. Scalar replacement 24. Register promotion Recap of Material

COMP 512, Fall Transformations intended to improve the code (continued ) 25. Adaptive blocksize choice (Waterman on MIPSPro) 26. Hoisting 27. Sinking (cross–jumping) 28. Procedure abstraction 29. Massalin’s Superoptimizer 30. Array linearization 31. Superlocal scheduling without code growth 32. Activation record merging 33. Dynamic code compression 34. Code motion of control structures 35. Profile-guided code positioning 36. Advanced topics in register allocation & scheduling Recap of Material

COMP 512, Fall And that’s the end of our story... Comp 512