1 / 14

Early Optimizations (Chapter 12)

Early Optimizations (Chapter 12). Constant-expression evaluation (constant folding), scalar replacement of aggregates, algebraic simplifications and reassociation, value numbering, copy propagation sparse conditional constant propagation

Download Presentation

Early Optimizations (Chapter 12)

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. Early Optimizations(Chapter 12)

  2. Constant-expression evaluation (constant folding), • scalar replacement of aggregates, • algebraic simplifications and reassociation, • value numbering, • copy propagation • sparse conditional constant propagation • First three are independent of Data flow analysis and last 3 are dependent of data flow analysis.

  3. Constant-expression evaluation • It refers to the evaluation at compile time of expression whose, operands are known to be constant. • The function returns true if its argument is a constant and false otherwise. • Ex Boolean values.

  4. Scalar replacement of aggregates • Makes other optimizations applicable to components of aggregates, such as C structures. • Use in very less compiler

  5. As in the example, first do scalar replacement on the snack record in main(), • Then the body of procedure color() into the call in main(), • Transform the resulting &snack->variety in the switch stmt into the equivalent snack. • Main() after constant propagation and dead-code elimination for the program.

  6. Algebraic simplifications and reassociation • Use algebraic properties of operators to simplify expressions. • Ex.

  7. Algebraic simplifications to floating point expressions

  8. Value numbering • It is one of several methods for determining that two computations are equivalent and eliminating one of them.

  9. Copy propagation • It is a transformation that, given an assignment xy for some variables x and y, replaces later uses of x with uses of y, as long as intervening instructions have not changed the value of either x or y

  10. Ex: Copy propagation

  11. Ex.

  12. Sparse conditional constant propagation • It is a transformation that, given and assignment xc for a variable x and a constant c, replaces later uses of x with uses of c as long as intervening assignments have not changed the value of x.

  13. Ex b3 in block B1 assigns the constant value 3 to b and no other assignment in the flow graph assigns to b Ex b3 in block B1 assigns the constant value 3 to b and no other assignment in the flowgraph assigns to b

More Related