Examples of SSA based optimizers Global Value Numbering
Examples of SSA based optimizers: Global Value Numbering
• Global Value Numbering (GVN): Common Sub-expression Elimination that does not depend on variable names. – Assume that there is a table as a set of projections from variables/expressions to their value numbers, such as { a -> 1, b -> 2, (⊕, 1, 2) -> 3 }, where each expression is represented as a tuple with an operator and value numbers of operands – The uses of the same definition have the same value number. – The left and right hand sides of a copy assignment such as a = b have the same value number. – Handling a statement x = a ⊕ b: 1. Search the value numbers of a and b in the table, where let a and b be 1 and 2 respectively. 2. If (⊕, 1, 2) is found in the table, its value number is assigned to x; otherwise, the new value number is assigned to (⊕, 1, 2) and x.
An example of GVN • GVN based on dominance relation: copy propagation + redundancy elimination t 1=5 a 1=x 1+t 1 s 1=5 b 1=x 1+s 1 q 1=b 1*5 p 1=a 1*5 t 1=5
An example of GVN • GVN based on dominance relation: copy propagation + redundancy elimination a 1=x 1+t 1 a 1=x 1+5 s 1=5 b 1=x 1+s 1 q 1=b 1*5 p 1=a 1*5 t 1=5 a 1=x 1+5
An example of GVN • GVN based on dominance relation: copy propagation + redundancy elimination a 1=x 1+5 s 1=5 b 1=x 1+s 1 q 1=b 1*5 p 1=a 1*5 t 1=5 a 1=x 1+5 s 1=5
An example of GVN • GVN based on dominance relation: copy propagation + redundancy elimination a 1=x 1+5 b 1=x 1+s 1 b 1=a 1 q 1=b 1*5 p 1=a 1*5 t 1=5 a 1=x 1+5 s 1=5 b 1=a 1
An example of GVN • GVN based on dominance relation: copy propagation + redundancy elimination a 1=x 1+5 q 1=b 1*5 q 1=a 1*5 p 1=a 1*5 t 1=5 a 1=x 1+5 s 1=5 b 1=a 1 q 1=a 1*5
An example of GVN • GVN based on dominance relation: copy propagation + redundancy elimination a 1=x 1+5 q 1=b 1*5 q 1=a 1*5 p 1=q 1 t 1=5 a 1=x 1+5 t 1=5 s 1=5 a 1=x 1+5 b 1=a 1 s 1=5 q 1=a 1*5 b 1=a 1 p 1=q 1 q 1=a 1*5
- Slides: 8