SSA-Based Constant Propagation in Compiler Construction - Prof. Rajiv Gupta, Study notes of Computer Science

The ssa-based sparse conditional constant propagation algorithm used in compiler construction. How the use of ssa-edges for faster propagation of constants from definitions to uses, handling executable vs non-executable edges, and maintaining two worklists for control flow edges and ssa edges contribute to the efficiency of the algorithm. The document also discusses the differences between def-use edges and ssa-edges and their impact on algorithm efficiency.

Typology: Study notes

Pre 2010

Uploaded on 03/28/2010

koofers-user-5lo
koofers-user-5lo 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
4/20/09
1
1
CS 201
Compiler Construction
Lecture 10
SSA-Based Sparse Conditional
Constant Propagation
Conditional Constant Propagation
SSA-based
algorithm is faster
than the previous
algorithm that was
presented earlier.
Basic Idea: Use
SSA-edges for
faster propagation
of constants from
definitions to uses.
2
pf3
pf4
pf5

Partial preview of the text

Download SSA-Based Constant Propagation in Compiler Construction - Prof. Rajiv Gupta and more Study notes Computer Science in PDF only on Docsity!

1

CS 201

Compiler Construction

Lecture 10

SSA-Based Sparse Conditional

Constant Propagation

Conditional Constant Propagation

SSA-based algorithm is faster than the previous algorithm that was presented earlier. Basic Idea: Use SSA-edges for faster propagation of constants from definitions to uses. 2

Contd..

Handling Executable vs Non-Executable Edges

  • At ϕ-functions non- executable operands have lattice value of top-undef-
  • This allows conditional constant propagation.
  • Process nodes only when they are known to be executable.
  • Non-executable SSA edges will transmit 3

Contd..

When can we process a SSA edge?

  • When we know the destination of the edge is executable.
  • Destination statement is executable when at least one of the incoming control flow edge is executable. Justification: In SSA form ecah use receives value from only one definition. Thus, no matter how we get to the use it will get the value from the same SSA-edge. 4

Contd..

  1. if e is CFG-edge from FlowWorkList then if ExecutableFlag(e)=false then ExecutableFlag(e) = true Perform Visitϕ for all ϕ-nodes at destination node. if only one incoming CFG-edges is TRUE then this this is the first visit to the node then Perform VisitExpression at the node if the node contains one outgoing CFGedge then add the edge to FlowWorkList 7

Contd..

  1. if e is SSA-edge from SSAWorkList then if destination of e is a ϕ-node then Perform Visitϕ elseif destination of e is an expression then examine ExecutableFlags for the CFG edges reaching that node and if any one flag is true then perform VisitExpression. 8

Contd..

Visitϕ For each operand in the ϕ-node examine the ExecutableFlag of the corresponding CFG-edge and set the operand’s lattice value as follows: CFG-edge executable  lattice value same as lattice value at the definition edge of the SSA-edge. CFG-edge non-executable lattice value is UNDEF or top. Compute the lattice value of the variable on the left hand side. 9

Contd..

VisitExpression Evaluate lattice value of the expression using lattice values of operands from places where they were defined. If lattice value changes then if expression is part of an assignment statement then add SSA-edge starting from left hand side to SSAWorkList elseif expression is conditional/predicate then based upon the result add appropriate CFG-edges to the FlowWorkList: TRUEtrue edge; FALSEfalse edge; and bottom  both edges. 10