1 / 27

Optimizing Compilers CISC 673 Spring 2011 Yet More Data flow analysis

Optimizing Compilers CISC 673 Spring 2011 Yet More Data flow analysis. John Cavazos University of Delaware. Overview. Additional Data Flow Problem Constant Propagation Generalization of Data Flow. Constant Propagation. Along every path to point p, variable v has same “known” value.

Download Presentation

Optimizing Compilers CISC 673 Spring 2011 Yet More Data flow analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Optimizing CompilersCISC 673Spring 2011Yet More Data flow analysis John Cavazos University of Delaware

  2. Overview • Additional Data Flow Problem • Constant Propagation • Generalization of Data Flow

  3. Constant Propagation • Along every path to point p, variable v has same “known” value

  4. Constant Propagation • Specialize computation at p based on v’s value

  5. … -2 -1 0 1 2 ... The Lattice of Constant Prop Constant Propagation Lattice Hasse diagram • Lattice is a poset with (V, ≤) • V meet (or join) operator • ≤ ordering operator

  6. Two Special Elements in Lattice • ⊤ (called top) • Not a Constant • ⊥ (called bottom) • Unknown

  7. Some Lattice Theory • Generalized Meet Operator ⊔ • Used at “merge” points

  8. Some Lattice Theory (cont’d) • Meet Operator (⊔) for Avail Expressions • Avail Expression (w/ sets):  • Avail Expression (w/ Bit Vectors): ⋀ • Produces Least Upper Bound (LUB) • X ⊔ Y = least element Z s.t. • X ≤ Z and Y ≤ Z

  9. Iterative Data Flow Analysis • Initialize non-entry nodes to identify element • Identity element for meet function • Remember last time: X ⋀ 1 = X

  10. Iterative Data Flow Analysis (cont’d) • If node function is monotone: • Each re-evaluation of node moves up the lattice, if it moves at all • If height of lattice is finite, must terminate

  11. Top ⊤ versus Bottom ⊥ • ⊤ means definitely NOT a constant • Inputs are ⊤ • ⊥ means Unknown or Undefined • Could be constant but we do not know!

  12. … -2 -1 0 1 2 ... The Lattice of Constant Prop More Lattice Theory: Ordering Op • ≤ ordering operator • ⊥ ≤ anything • ∀x ⊥ ⊔ x = x • anything ≤ ⊤ • ∀x x ⊔ ⊤= ⊤ • ∀x x ⊔ x = x

  13. Relate to Constant Prop?! • i and j are integer values • i ⊔ i = i • i ⊔ j = ⊤ if i ≠ j

  14. What is X in Block 3? 1. 2. 3.

  15. What is X in Block 3? 1. 2. 3. x is ⊤

  16. Constant Propagation Problem • Variable v has constant value c at point p, iff ∀ paths from entry to p, the most recently assigned value for v is c

  17. Constant Prop Example Meet Operator = ⊔ Identity= ? X ⊔ ? = X

  18. Constant Prop Example Meet Operator = ⊔ Identify= ⊥ X ⊔ ⊥ = X Initial Condition?

  19. Constant Prop Example Meet Operator = ⊔ Identify= ⊥ X ⊔ ⊥ = X Initial Condition Boundary Condition? XYZ ⊥⊥⊥ ⊥⊥⊥ ⊥⊥⊥ ⊥⊥⊥

  20. Constant Prop Example ⊥⊥⊥ Meet Operator = ⊔ Identify= ⊥ X ⊔ ⊥ = X Initial Condition Boundary Condition XYZ 1. ⊥⊥⊥ 2. 3. ⊥⊥⊥ ⊥⊥⊥ 4. ⊥⊥⊥

  21. Constant Prop Example ⊥⊥⊥ XYZ out1= ??? 1. ⊥⊥⊥ 2. 3. ⊥⊥⊥ ⊥⊥⊥ 4. ⊥⊥⊥

  22. Constant Prop Example ⊥⊥⊥ XYZ out1= 1⊥⊥ out2= ??? 1. 1⊥⊥ ⊥⊥⊥ 2. 3. ⊥⊥⊥ ⊥⊥⊥ 4. ⊥⊥⊥

  23. Constant Prop Example ⊥⊥⊥ XYZ out1= 1⊥⊥ out2= 023 out3= ??? 1. 1⊥⊥ ⊥⊥⊥ 2. 3. ⊥⊥⊥ ⊥⊥⊥ 023 4. ⊥⊥⊥

  24. Constant Prop Example ⊥⊥⊥ XYZ out1= 1⊥⊥ out2= 023 out3= 12⊥ out4= ??? 1. 1⊥⊥ ⊥⊥⊥ 2. 3. ⊥⊥⊥ ⊥⊥⊥ 12⊥ 023 4. ⊥⊥⊥

  25. Constant Prop Example ⊥⊥⊥ XYZ out1= 1⊥⊥ out2= 023 out3= 12⊥ out4= ⊤23 1. 1⊥⊥ ⊥⊥⊥ 2. 3. ⊥⊥⊥ ⊥⊥⊥ Does this make sense? 12⊥ 023 4. ⊥⊥⊥ ⊤23

  26. Next Time • Static-Single Assignment (SSA Form) • Read Efficiently computing static single assignment form and the control dependence graph, Cytron et al. http://portal.acm.org/citation.cfm?id=115320

  27. Next Time • Intelligent Compilation

More Related