Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists...

37
1 Topic 9 : Static Single Assignment COS 320 Compiling Techniques Princeton University Spring 2018 Prof. David August

Transcript of Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists...

Page 1: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

1

Topic 9: Static Single Assignment

COS 320

Compiling Techniques

Princeton University Spring 2018

Prof. David August

Page 2: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Def-Use Chains, Use-Def Chains

Page 3: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Use-Def Chains, Def-Use Chains

Page 4: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Static Single Assignment

Page 5: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Why SSA?

Page 6: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Conversion to SSA Code

Page 7: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Conversion to SSA Form

Page 8: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Conversion to SSA Form

Page 9: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Conversion to SSA Form

Page 10: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Conversion to SSA Form

Page 11: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Conversion to SSA Form

Page 12: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Dominance Frontier

Page 13: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Dominance Frontier

Page 14: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Dominance Frontier Computation

Page 15: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Example

Page 16: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Dominator Analysis

Page 17: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Example

Page 18: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Example

Page 19: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Example

Page 20: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Example

Page 21: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

Static Single Assignment

Page 22: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Dominance Property

Page 23: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Dead Code Elimination

Page 24: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Dead Code Elimination

Page 25: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Simple Constant Propagation

Page 26: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Simple Constant Propagation

Page 27: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant Propagation

Page 28: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant Propagation

Page 29: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant Propagation

Page 30: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant Propagation

Page 31: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant Propagation

Page 32: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant Propagation

Page 33: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant PropagationExample

Page 34: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant PropagationExample

Page 35: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant PropagationExample

Page 36: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant PropagationExample

Page 37: Topic 9: Static Single Assignment...Given d: t = x op y t is live at end of node d if there exists path from end of d to use of t that does not go through definition of t. if program

SSA Conditional Constant PropagationExample