Program Representation
Dominator Relationships
Last Time
Dominators
Live variable analysis
Constant propagation
leads us to SSA and how to connect uses and def
Today
DOM(v) = the set of all vertices that dominate v.
All vertices dominate themselves, v
Advanced Topics
Alias Analysis
Last Time
What is pointer analysis?
Experimental Methodology
For umanaged languages like C, C+, and
managed languages like C#, Java, Modula-3
Today
Goal: given two memory references, m and n, and
a program point, p, can m
Interprocedural Analysis
Dealing with Procedures
Course so far:
Terminology
Control Flow Representation
Dataow Representation
SSA form
Classic DefUse and UseDef Chains
Optimizations
Scheduling
Register Allocation
int a, e
/ globals
procedure foo(va
Advanced Topics
Which Loops are Parallel?
Optimization for parallel machines and memory
hierarchies
review
do I = 1, N
do J = 1, N
S1
A(I,J) = A(I,J-1) + 1
Last Time
do I = 1, N
do J = 1, N
S2
A(I,J) = A(I-1,J-1) + 1
Dependence analysis
I
Today
do I = 1,
CS 380C
Advanced Compiler
Techniques
KathrynSMcKinley
TheUniversityofTexasatAustin
Lecture26
CS380C
1
Goals
Intellectual development
Critical thinking and writing about original
source material
Software design and problem solving
Deep understanding of
CS 380C: Advanced Topics in Compilers
Assignment 3: Loop analysis
Due: February 18th
February 11, 2016
Late submission policy: Submission can be at the most 2 days late. There will be a 10%
penalty for each day after the due date (cumulative).
The goal of
CS 380C: Advanced Topics in Compilers
Assignment 6: Assembly Code Generation
Due: March 31st
March 3, 2016
Late submission policy: Submission can be at the most 2 days late. There will be a 10%
penalty for each day after the due date (cumulative).
The goa
Putting Data Flow Analysis to Work
Last Time
Iterative Worklist Algorithm via Reaching Denitions
Live Variable Analysis
Can a variable v at a point p be used before it is
redened along some path starting at p?
USE( p) - the set of variables that may be us
More Data Flow Analysis
Work List Iterative Algorithm
Last Time
for v V
/
IN(v) = 0
OUT(v) = GEN(v)
endfor
worklist v V
/
while ( worklist = 0 )
pick and remove a node v from worklist
Data Flow Analysis
Data Flow Frameworks
Constant Propagation Framewo
Data Flow Analysis and Optimizations
Last Time
Data Flow Analysis
Data ow analysis tells us things we want to know
about programs, for example:
Control Flow Graphs
Is this computation loop invariant?
Which denition reaches this use?
Today
Is this valu
Control Flow Analysis
Computing Static Single Assignment (SSA) Form
Last Time
Overview
Constant propagation
What is SSA?
Dominator relationships
Advantages of SSA over use-def chains
Flavors of SSA
Today
Dominance frontier
Static Single Assignment
Optimization
Loop Optimization
Loops are important, they execute often
Last Time
Building SSA
typically, some regular access pattern
regularity opportunity for improvement
repetition savings are multiplied
Basic denition, and why it is useful
How to bu
More Optimizations
Common Subexpression Elimination (Example)
Given A[i][j] = A[i][j] + 1, and assuming
Last Time
Loop invariant code motion
1. row-major order
Loop induction variables
2. each array element is 4 bytes, and
3. R rows in the array
Today
w
Scheduling
What makes instruction scheduling hard?
Previously
Instruction data path
Value Numbering
IF
Reg
ALU
DM
Reg2
Today: Scheduling to Minimize Register pressure
IF: Instruction Fetch
Reg: Instruction Decode/Register Fetch
ALU: Execute/Fetch
DM: Mem
380C
Last Time
Today
Interactionsofscheduling Interactionsofscheduling
andregisterusage
andinstructionlevel
parallelism
Lecture11
CS380C
1
Shape of Expressions
Proebsting&Fischerassumeafixedexpression
tree
Huntetal.reorganizecommutativeand
associativeo
Where we are
Register Allocation via Graph Coloring
Course so far
The abstraction
Program representation
G. J. Chaitin, M. A. Auslander, A. K. Chandra, J.
Cocke, M. E. Hopkins, and P. W. Markstein,
Register Allocation via Coloring, Computer
Languages,
Graph Coloring Register Allocation
Rematerialization
Some expressions are especially simple to recompute:
Last Time
Chaitin et al.
Operands are constant
(though not necessarily known)
Briggs et al.
Operands are available globally
Today
Chaitin calls t
Register Allocation
Motivation
Fast compilation times are becoming increasingly
important
Previously
Graph Coloring Allocators
Chaitin style
dynamic compilation (JIT)
Briggs enhancements
whole program optimization
production compilers
Today
Register
Dynamic Compilation
Inlining
Advanced Topics:
Benets and costs
Dynamic compilation
Direct benet: reduced call overhead
Today:
allocating and deallocating local variables
Finish How to Compile
saving and restoring registers
Inlining in ahead of time
Solving fixpoint equations
Goal
Many problems in programming languages can be formulated as the
solution of a set of mutually recursive equations:
D: set, f,g:DxD D
x = f(x,y)
y = g(x,y)
Examples
Parsing: first/follow sets in LL(k) parsing
PL semantics