1 / 7

Global Common Subexpression Elimination

Global Common Subexpression Elimination. Available Expression Analysis Eliminating CSEs. Global Common Subexpression. Available Expression. Availability of an expression E at point P Definition: Along every path to P in the flow graph: E must be evaluated at least once

jun
Download Presentation

Global Common Subexpression Elimination

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. Global Common Subexpression Elimination Available Expression Analysis Eliminating CSEs

  2. Global Common Subexpression

  3. Available Expression • Availability of an expression E at point P • Definition: Along every path to P in the flow graph: • E must be evaluated at least once • No variables in E redefined after the last evaluation • Observations: E may have different values on different paths; variables holding value may have been overwritten

  4. Formulating the Problem • Domain: A bit vector, a bit for each lexically unique expression in the program • Forward or Backward problem? • Meet operator? • check commutative, idempotent, associative • Partial ordering • Lattice elements? • Top? Bottom? • Initialization for iterative algorithm

  5. Transfer Functions • Can use the same equation as reaching definitions • out[b] = gen[b] ∪ (in[b] – kill[b]) • Start with the transfer function for a single instruction • When does the instruction generate an expression? • When does it kill an expression? • Calculate transfer functions for basic blocks • Compose individual instruction transfer functions

  6. in1 out1 = gen1 ∪ (in1 – kill1) out2 = gen2 ∪ (in2 – kill2) Composing Transfer Functions • Derive the transfer function for an entire block • Since out1 = in2, we can simplify: • out2 = gen2 ∪ ((gen1 ∪ (in1 – kill1)) – kill2) out2 = gen2 ∪ (gen1 – kill2) ∪ (in1 – (kill1 ∪ kill2)) • Result • gen = gen2 ∪ (gen1 – kill2) • kill = kill1 ∪ kill2

  7. Eliminating CSEs • Available expressions (across basic blocks) • Provide the set of available expressions at each block header • Value numbering (within a basic block) • Initialize value table with available expressions

More Related