SlideShare a Scribd company logo
Code Optimization Chapter 9 (1 st  ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2009
The Code Optimizer ,[object Object],[object Object],[object Object],Front end Code generator Code optimizer Control- flow analysis Data- flow analysis Transfor- mations
Determining Loops in Flow Graphs: Dominators ,[object Object],[object Object],[object Object],[object Object],[object Object]
Dominator Trees 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree
Natural Loops ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Natural Inner Loops Example 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree Natural loop for 7  dom  10 Natural loop for 3  dom  4 Natural loop for 4  dom  7
Natural Outer Loops Example 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree Natural loop for 1  dom  9 Natural loop for 3  dom  8
Pre-Headers ,[object Object],[object Object],Header Header Preheader
Reducible Flow Graphs ,[object Object],1 2 3 4 Example of a reducible CFG 1 2 3 Example of a nonreducible CFG
Global Data-Flow Analysis ,[object Object],[object Object],d1:  i := m-1 d2:  j := n d3:  j := j-1 B1: B2: B3: out [B1] =  gen [B1] = {d1, d2} out [B2] =  gen [B2]    {d1} = {d1, d3} d1 reaches B2 and B3 and d2 reaches B2, but not B3 because d2 is killed in B2
Reaching Definitions S d :  a:=b+c Then, the data-flow equations for  S  are: gen [ S ] = { d } kill [ S ] =  D a  - { d } out [ S ] =  gen [ S ]    ( in [ S ] -  kill [ S ]) where  D a  = all definitions of  a  in the region of code is of the form
Reaching Definitions S gen [ S ] =  gen [ S 2 ]    ( gen [ S 1 ] -  kill [ S 2 ]) kill [ S ] =  kill [ S 2 ]    ( kill [ S 1 ] -  gen [ S 2 ]) in [ S 1 ] =  in [ S ] in [ S 2 ] =  out [ S 1 ] out [ S ] =  out [ S 2 ] is of the form S 2 S 1
Reaching Definitions S gen [ S ] =  gen [ S 1 ]     gen [ S 2 ]  kill [ S ] =  kill [ S 1 ]     kill [ S 2 ] in [ S 1 ] =  in [ S ] in [ S 2 ] =  in [ S ] out [ S ] =  out [ S 1 ]     out [ S 2 ] is of the form S 2 S 1
Reaching Definitions S gen [ S ] =  gen [ S 1 ]  kill [ S ] =  kill [ S 1 ] in [ S 1 ] =  in [ S ]     gen [ S 1 ] out [ S ] =  out [ S 1 ] is of the form S 1
Example Reaching Definitions d 1 :  i := m-1; d 2 :  j := n; d 3 :  a := u1;   do d 4 :  i := i+1; d 5 :  j := j-1;   if e1 then d 6 :  a := u2   else d 7 :  i := u3   while e2 ; gen ={ d 1 } kill ={ d 4 ,  d 7 } d 1 gen ={ d 2 } kill ={ d 5 } d 2 gen ={ d 1 , d 2 } kill ={ d 4 , d 5 , d 7 } ; d 3 gen ={ d 3 } kill ={ d 6 } gen ={ d 1 , d 2 , d 3 } kill ={ d 4 , d 5 , d 6 , d 7 } ; gen ={ d 3 , d 4 , d 5 , d 6 , d 7 } kill ={ d 1 , d 2 } do ; gen ={ d 4 } kill ={ d 1 ,  d 7 } d 4 ; gen ={ d 5 } kill ={ d 2 } d 5 if e1 d 6 d 7 e1 gen ={ d 6 } kill ={ d 3 } gen ={ d 7 } kill ={ d 1 , d 4 } gen ={ d 4 , d 5 } kill ={ d 1 , d 2 , d 7 } gen ={ d 4 , d 5 , d 6 , d 7 } kill ={ d 1 , d 2 } gen ={ d 4 , d 5 , d 6 , d 7 } kill ={ d 1 , d 2 } gen ={ d 6 , d 7 } kill ={}
Using Bit-Vectors to Compute Reaching Definitions d 1 :  i := m-1; d 2 :  j := n; d 3 :  a := u1;   do d 4 :  i := i+1; d 5 :  j := j-1;   if e1 then d 6 :  a := u2   else d 7 :  i := u3   while e2 ; d 1 d 2 ; d 3 ; 0011111 1100000 do ; d 4 ; d 5 if e1 d 6 d 7 e1 1110000 0001111 1100000 0001101 1000000 0001001 0100000 0000100 0010000 0000010 0001111 1100000 0001111 1100000 0001100 1100001 0001000 1000001 0000100 0100000 0000010 0010000 0000001 1001000 0000011 0000000
Accuracy, Safeness, and Conservative Estimations ,[object Object],[object Object],[object Object]
Reaching Definitions are a Conservative (Safe) Estimation S 2 S 1 Suppose this branch is never taken Estimation: gen [ S ] =  gen [ S 1 ]     gen [ S 2 ]  kill [ S ] =  kill [ S 1 ]     kill [ S 2 ] Accurate: gen’ [ S ] =  gen [ S 1 ] ⊆  gen [ S ]  kill’ [ S ] =  kill [ S 1 ] ⊇  kill [ S ]
Reaching Definitions are a Conservative (Safe) Estimation in [ S 1 ] =  in [ S ]     gen [ S 1 ] S 1 Why  gen ? S is of the form The problem is that in [ S 1 ] =  in [ S ]     out [ S 1 ] makes more sense, but we cannot solve this  directly, because  out [ S 1 ] depends on  in [ S 1 ]
Reaching Definitions are a Conservative (Safe) Estimation d :  a:=b+c We have: (1)  in [ S 1 ] =  in [ S ]     out [ S 1 ] (2)  out [ S 1 ] =  gen [ S 1 ]    ( in [ S 1 ] -  kill [ S 1 ]) Solve  in [ S 1 ] and  out [ S 1 ] by estimating  in 1 [ S 1 ] using safe but approximate  out [ S 1 ]=  , then re-compute  out 1 [ S 1 ] using (2) to estimate  in 2 [ S 1 ], etc. in 1 [ S 1 ] = (1)   in [ S ]     out [ S 1 ] =  in [ S ] out 1 [ S 1 ] = (2)   gen [ S 1 ]    ( in 1 [ S 1 ] -  kill [ S 1 ]) =  gen [ S 1 ]    ( in [ S ] -  kill [ S 1 ]) in 2 [ S 1 ] = (1)   in [ S ]     out 1 [ S 1 ] =  in [ S ]     gen [ S 1 ]    ( in [ S ] -  kill [ S 1 ]) =  in [ S ]     gen [ S 1 ]  out 2 [ S 1 ] = (2)   gen [ S 1 ]    ( in 2 [ S 1 ] -  kill [ S 1 ]) =  gen [ S 1 ]    ( in [ S ]     gen [ S 1 ] -  kill [ S 1 ]) =  gen [ S 1 ]    ( in [ S ] -  kill [ S 1 ])  Because  out 1 [ S 1 ] =  out 2 [ S 1 ], and therefore  in 3 [ S 1 ] =  in 2 [ S 1 ], we conclude that in [ S 1 ] =  in [ S ]     gen [ S 1 ]

More Related Content

What's hot

9 chap
9 chap9 chap
Surds & indices in business mathematics
Surds & indices in business mathematics Surds & indices in business mathematics
Surds & indices in business mathematics
Dr. Trilok Kumar Jain
 
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ssusere0a682
 
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Moses Boudourides
 
ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-
ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-
ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-
ssusere0a682
 
Multilayerity within multilayerity? On multilayer assortativity in social net...
Multilayerity within multilayerity? On multilayer assortativity in social net...Multilayerity within multilayerity? On multilayer assortativity in social net...
Multilayerity within multilayerity? On multilayer assortativity in social net...
Moses Boudourides
 
Potencias resueltas 1eso (1)
Potencias resueltas 1eso (1)Potencias resueltas 1eso (1)
Potencias resueltas 1eso (1)
Lina Manriquez
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
computerangel85
 
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Moses Boudourides
 
The chain rule
The chain ruleThe chain rule
The chain rule
Shaun Wilson
 
Topics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and AssortativityTopics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and Assortativity
Moses Boudourides
 
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Moses Boudourides
 
Maths ms
Maths msMaths ms
Maths ms
B Bhuvanesh
 
solucionario de purcell 3
solucionario de purcell 3solucionario de purcell 3
solucionario de purcell 3
José Encalada
 
ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-
ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-
ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-
ssusere0a682
 
Quadratic Expressions
Quadratic ExpressionsQuadratic Expressions
Quadratic Expressions
2IIM
 
2621008 - C++ 4
2621008 -  C++ 42621008 -  C++ 4
2621008 - C++ 4
S.Ali Sadegh Zadeh
 
solucionario de purcell 2
solucionario de purcell 2solucionario de purcell 2
solucionario de purcell 2
José Encalada
 
Capitulo 4 Soluciones Purcell 9na Edicion
Capitulo 4 Soluciones Purcell 9na EdicionCapitulo 4 Soluciones Purcell 9na Edicion
Capitulo 4 Soluciones Purcell 9na Edicion
FranciscoAlfonso TorresVeliz
 

What's hot (19)

9 chap
9 chap9 chap
9 chap
 
Surds & indices in business mathematics
Surds & indices in business mathematics Surds & indices in business mathematics
Surds & indices in business mathematics
 
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
 
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
 
ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-
ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-
ゲーム理論NEXT コア第4回(最終回) -平衡ゲームとコア-
 
Multilayerity within multilayerity? On multilayer assortativity in social net...
Multilayerity within multilayerity? On multilayer assortativity in social net...Multilayerity within multilayerity? On multilayer assortativity in social net...
Multilayerity within multilayerity? On multilayer assortativity in social net...
 
Potencias resueltas 1eso (1)
Potencias resueltas 1eso (1)Potencias resueltas 1eso (1)
Potencias resueltas 1eso (1)
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
Topics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and AssortativityTopics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and Assortativity
 
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
 
Maths ms
Maths msMaths ms
Maths ms
 
solucionario de purcell 3
solucionario de purcell 3solucionario de purcell 3
solucionario de purcell 3
 
ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-
ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-
ゲーム理論BASIC 演習24 -公理から求めるナッシュ交渉解-
 
Quadratic Expressions
Quadratic ExpressionsQuadratic Expressions
Quadratic Expressions
 
2621008 - C++ 4
2621008 -  C++ 42621008 -  C++ 4
2621008 - C++ 4
 
solucionario de purcell 2
solucionario de purcell 2solucionario de purcell 2
solucionario de purcell 2
 
Capitulo 4 Soluciones Purcell 9na Edicion
Capitulo 4 Soluciones Purcell 9na EdicionCapitulo 4 Soluciones Purcell 9na Edicion
Capitulo 4 Soluciones Purcell 9na Edicion
 

Similar to Ch10

Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
jacksnathalie
 
Obj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance FormulasObj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance Formulas
smiller5
 
Succesive differntiation
Succesive differntiationSuccesive differntiation
Succesive differntiation
JaydevVadachhak
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
Sanjay Singh
 
Rsa documentation
Rsa documentationRsa documentation
Rsa documentation
Farag Zakaria
 
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in MatlabMathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in Matlab
COMSATS Abbottabad
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
Ken'ichi Matsui
 
Understanding Reed-Solomon code
Understanding Reed-Solomon codeUnderstanding Reed-Solomon code
Understanding Reed-Solomon code
继顺(Jeffrey) 王
 
09 p.t (straight line + circle) solution
09 p.t (straight line + circle) solution09 p.t (straight line + circle) solution
09 p.t (straight line + circle) solution
AnamikaRoy39
 
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
ADVANCED   ALGORITHMS-UNIT-3-Final.pptADVANCED   ALGORITHMS-UNIT-3-Final.ppt
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
ssuser702532
 
Cryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.pptCryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.ppt
the9amit
 
3 complex numbers part 3 of 3
3 complex numbers part 3 of 33 complex numbers part 3 of 3
3 complex numbers part 3 of 3
naveenkumar9211
 
K means clustering
K means clusteringK means clustering
K means clustering
Ahmedasbasb
 
CH04.ppt
CH04.pptCH04.ppt
On derivations of black scholes greek letters
On derivations of black scholes greek lettersOn derivations of black scholes greek letters
On derivations of black scholes greek letters
Alexander Decker
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
theijes
 
presentation
presentationpresentation
presentation
Gábor Bakos
 
Starr pvt. ltd. rachit's group ppt (1)
Starr pvt. ltd. rachit's group ppt (1)Starr pvt. ltd. rachit's group ppt (1)
Starr pvt. ltd. rachit's group ppt (1)
Rachit Mehta
 

Similar to Ch10 (18)

Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
 
Obj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance FormulasObj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance Formulas
 
Succesive differntiation
Succesive differntiationSuccesive differntiation
Succesive differntiation
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
 
Rsa documentation
Rsa documentationRsa documentation
Rsa documentation
 
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in MatlabMathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in Matlab
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
Understanding Reed-Solomon code
Understanding Reed-Solomon codeUnderstanding Reed-Solomon code
Understanding Reed-Solomon code
 
09 p.t (straight line + circle) solution
09 p.t (straight line + circle) solution09 p.t (straight line + circle) solution
09 p.t (straight line + circle) solution
 
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
ADVANCED   ALGORITHMS-UNIT-3-Final.pptADVANCED   ALGORITHMS-UNIT-3-Final.ppt
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
 
Cryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.pptCryptography and Network Security chapter 4.ppt
Cryptography and Network Security chapter 4.ppt
 
3 complex numbers part 3 of 3
3 complex numbers part 3 of 33 complex numbers part 3 of 3
3 complex numbers part 3 of 3
 
K means clustering
K means clusteringK means clustering
K means clustering
 
CH04.ppt
CH04.pptCH04.ppt
CH04.ppt
 
On derivations of black scholes greek letters
On derivations of black scholes greek lettersOn derivations of black scholes greek letters
On derivations of black scholes greek letters
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
 
presentation
presentationpresentation
presentation
 
Starr pvt. ltd. rachit's group ppt (1)
Starr pvt. ltd. rachit's group ppt (1)Starr pvt. ltd. rachit's group ppt (1)
Starr pvt. ltd. rachit's group ppt (1)
 

More from kinnarshah8888

Yuva Msp All
Yuva Msp AllYuva Msp All
Yuva Msp All
kinnarshah8888
 
Yuva Msp Intro
Yuva Msp IntroYuva Msp Intro
Yuva Msp Intro
kinnarshah8888
 
Ch6
Ch6Ch6
Ch9c
Ch9cCh9c
Ch8a
Ch8aCh8a
Ch5a
Ch5aCh5a
Ch9b
Ch9bCh9b
Ch9a
Ch9aCh9a
Ch7
Ch7Ch7
Ch3
Ch3Ch3
Ch2
Ch2Ch2
Ch4b
Ch4bCh4b
Ch4a
Ch4aCh4a
Ch8b
Ch8bCh8b
Ch5b
Ch5bCh5b
Ch4c
Ch4cCh4c
Ch1
Ch1Ch1

More from kinnarshah8888 (17)

Yuva Msp All
Yuva Msp AllYuva Msp All
Yuva Msp All
 
Yuva Msp Intro
Yuva Msp IntroYuva Msp Intro
Yuva Msp Intro
 
Ch6
Ch6Ch6
Ch6
 
Ch9c
Ch9cCh9c
Ch9c
 
Ch8a
Ch8aCh8a
Ch8a
 
Ch5a
Ch5aCh5a
Ch5a
 
Ch9b
Ch9bCh9b
Ch9b
 
Ch9a
Ch9aCh9a
Ch9a
 
Ch7
Ch7Ch7
Ch7
 
Ch3
Ch3Ch3
Ch3
 
Ch2
Ch2Ch2
Ch2
 
Ch4b
Ch4bCh4b
Ch4b
 
Ch4a
Ch4aCh4a
Ch4a
 
Ch8b
Ch8bCh8b
Ch8b
 
Ch5b
Ch5bCh5b
Ch5b
 
Ch4c
Ch4cCh4c
Ch4c
 
Ch1
Ch1Ch1
Ch1
 

Recently uploaded

ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 

Recently uploaded (20)

ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 

Ch10

  • 1. Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2009
  • 2.
  • 3.
  • 4. Dominator Trees 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree
  • 5.
  • 6. Natural Inner Loops Example 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree Natural loop for 7 dom 10 Natural loop for 3 dom 4 Natural loop for 4 dom 7
  • 7. Natural Outer Loops Example 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree Natural loop for 1 dom 9 Natural loop for 3 dom 8
  • 8.
  • 9.
  • 10.
  • 11. Reaching Definitions S d : a:=b+c Then, the data-flow equations for S are: gen [ S ] = { d } kill [ S ] = D a - { d } out [ S ] = gen [ S ]  ( in [ S ] - kill [ S ]) where D a = all definitions of a in the region of code is of the form
  • 12. Reaching Definitions S gen [ S ] = gen [ S 2 ]  ( gen [ S 1 ] - kill [ S 2 ]) kill [ S ] = kill [ S 2 ]  ( kill [ S 1 ] - gen [ S 2 ]) in [ S 1 ] = in [ S ] in [ S 2 ] = out [ S 1 ] out [ S ] = out [ S 2 ] is of the form S 2 S 1
  • 13. Reaching Definitions S gen [ S ] = gen [ S 1 ]  gen [ S 2 ] kill [ S ] = kill [ S 1 ]  kill [ S 2 ] in [ S 1 ] = in [ S ] in [ S 2 ] = in [ S ] out [ S ] = out [ S 1 ]  out [ S 2 ] is of the form S 2 S 1
  • 14. Reaching Definitions S gen [ S ] = gen [ S 1 ] kill [ S ] = kill [ S 1 ] in [ S 1 ] = in [ S ]  gen [ S 1 ] out [ S ] = out [ S 1 ] is of the form S 1
  • 15. Example Reaching Definitions d 1 : i := m-1; d 2 : j := n; d 3 : a := u1; do d 4 : i := i+1; d 5 : j := j-1; if e1 then d 6 : a := u2 else d 7 : i := u3 while e2 ; gen ={ d 1 } kill ={ d 4 , d 7 } d 1 gen ={ d 2 } kill ={ d 5 } d 2 gen ={ d 1 , d 2 } kill ={ d 4 , d 5 , d 7 } ; d 3 gen ={ d 3 } kill ={ d 6 } gen ={ d 1 , d 2 , d 3 } kill ={ d 4 , d 5 , d 6 , d 7 } ; gen ={ d 3 , d 4 , d 5 , d 6 , d 7 } kill ={ d 1 , d 2 } do ; gen ={ d 4 } kill ={ d 1 , d 7 } d 4 ; gen ={ d 5 } kill ={ d 2 } d 5 if e1 d 6 d 7 e1 gen ={ d 6 } kill ={ d 3 } gen ={ d 7 } kill ={ d 1 , d 4 } gen ={ d 4 , d 5 } kill ={ d 1 , d 2 , d 7 } gen ={ d 4 , d 5 , d 6 , d 7 } kill ={ d 1 , d 2 } gen ={ d 4 , d 5 , d 6 , d 7 } kill ={ d 1 , d 2 } gen ={ d 6 , d 7 } kill ={}
  • 16. Using Bit-Vectors to Compute Reaching Definitions d 1 : i := m-1; d 2 : j := n; d 3 : a := u1; do d 4 : i := i+1; d 5 : j := j-1; if e1 then d 6 : a := u2 else d 7 : i := u3 while e2 ; d 1 d 2 ; d 3 ; 0011111 1100000 do ; d 4 ; d 5 if e1 d 6 d 7 e1 1110000 0001111 1100000 0001101 1000000 0001001 0100000 0000100 0010000 0000010 0001111 1100000 0001111 1100000 0001100 1100001 0001000 1000001 0000100 0100000 0000010 0010000 0000001 1001000 0000011 0000000
  • 17.
  • 18. Reaching Definitions are a Conservative (Safe) Estimation S 2 S 1 Suppose this branch is never taken Estimation: gen [ S ] = gen [ S 1 ]  gen [ S 2 ] kill [ S ] = kill [ S 1 ]  kill [ S 2 ] Accurate: gen’ [ S ] = gen [ S 1 ] ⊆ gen [ S ] kill’ [ S ] = kill [ S 1 ] ⊇ kill [ S ]
  • 19. Reaching Definitions are a Conservative (Safe) Estimation in [ S 1 ] = in [ S ]  gen [ S 1 ] S 1 Why gen ? S is of the form The problem is that in [ S 1 ] = in [ S ]  out [ S 1 ] makes more sense, but we cannot solve this directly, because out [ S 1 ] depends on in [ S 1 ]
  • 20. Reaching Definitions are a Conservative (Safe) Estimation d : a:=b+c We have: (1) in [ S 1 ] = in [ S ]  out [ S 1 ] (2) out [ S 1 ] = gen [ S 1 ]  ( in [ S 1 ] - kill [ S 1 ]) Solve in [ S 1 ] and out [ S 1 ] by estimating in 1 [ S 1 ] using safe but approximate out [ S 1 ]=  , then re-compute out 1 [ S 1 ] using (2) to estimate in 2 [ S 1 ], etc. in 1 [ S 1 ] = (1) in [ S ]  out [ S 1 ] = in [ S ] out 1 [ S 1 ] = (2) gen [ S 1 ]  ( in 1 [ S 1 ] - kill [ S 1 ]) = gen [ S 1 ]  ( in [ S ] - kill [ S 1 ]) in 2 [ S 1 ] = (1) in [ S ]  out 1 [ S 1 ] = in [ S ]  gen [ S 1 ]  ( in [ S ] - kill [ S 1 ]) = in [ S ]  gen [ S 1 ] out 2 [ S 1 ] = (2) gen [ S 1 ]  ( in 2 [ S 1 ] - kill [ S 1 ]) = gen [ S 1 ]  ( in [ S ]  gen [ S 1 ] - kill [ S 1 ]) = gen [ S 1 ]  ( in [ S ] - kill [ S 1 ]) Because out 1 [ S 1 ] = out 2 [ S 1 ], and therefore in 3 [ S 1 ] = in 2 [ S 1 ], we conclude that in [ S 1 ] = in [ S ]  gen [ S 1 ]