Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Analysis: Reaching Definition & Elimination of Interval, Live Variable, and Common Sub-exp, Slides of Computer Science

A part of lecture 30 in module 15 of 'reaching definition' in multi-core architecture. It covers various techniques for static program analysis, including interval analysis, live variable analysis, and common sub-expression elimination. These techniques help in optimizing code by identifying redundant expressions, dead code, and live variables.

Typology: Slides

2012/2013

Uploaded on 03/28/2013

ekanath
ekanath 🇮🇳

3.8

(4)

80 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Objectives_template
file:///D|/...ary,%20Dr.%20Sanjeev%20K%20Aggrwal%20&%20Dr.%20Rajat%20Moona/Multi-core_Architecture/lecture%2030/30_1.htm[6/14/2012 12:10:21 PM]
Module 15: Reaching Definition
Lecture 30: Analysis
The Lecture Contains:
Interval Analysis
Backward Analysis
Available Expression
Live Variable Analysis
Very Busy Expression
Common Sub-expression Elimination
Copy Propagation
Loop Invariant Computations
Performing Code Motion
Elimination of Induction Variable
Detection of Induction Variables
Strength Reduction
Pointers
A Simple Pointer Language
Transfer Function
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Analysis: Reaching Definition & Elimination of Interval, Live Variable, and Common Sub-exp and more Slides Computer Science in PDF only on Docsity!

Module 15: Reaching Definition

Lecture 30: Analysis

The Lecture Contains:

Interval Analysis

Backward Analysis

Available Expression

Live Variable Analysis

Very Busy Expression

Common Sub-expression Elimination

Copy Propagation

Loop Invariant Computations

Performing Code Motion

Elimination of Induction Variable

Detection of Induction Variables

Strength Reduction

Pointers

A Simple Pointer Language

Transfer Function

Module 15: Reaching Definition

Lecture 30: Analysis

For block

For the while loop

Interval Analysis

Interval analysis is trivial; it is identical to structural analysis. Only three kinds of regions appear: general acyclic, proper, and improper.

Backward Analysis

Harder to model as single exit is not guaranteed in programs For constructs with single exit we can ’turn the equations around’

Module 15: Reaching Definition

Lecture 30: Analysis

Example

U is the universal set of all expressions appearing in a program In[B] and out[B] are sets of expressions available at the beginning/end of B E-gen[B] and e-kill[B] are sets of expressions generated and killed in B Out[B] = in[B] - e-kill[B] e-gen[B] In[B] = out[P] for B not initial In[B] = where B 0 is the initial block Initialization: In[B 0 ] = Out[B 0 ] = e-gen[B 0 ] Out[B] = U - e-kill[B] if B is not an entry block

Live Variable Analysis

Used for dead code elimination In[B] and out[B] are sets of live variables at entry and exit Def[B] set of variables assigned value in B prior to use in B Use[B] set of variables whose value may be used before definition in B In[B] = use[B] S (out[B] - def[B]) Out[B] = S in[S] where S is successor of B A variable is live coming into a block if EITHER is it used in the block before re-definition OR it is live coming out and not re-defined A variable is live coming out of a block if it is live coming into one of its successors Initialization: in[B]= for all B

Module 15: Reaching Definition

Lecture 30: Analysis

Very Busy Expression

In[B] and Out[B] are sets of VBE at the beginning and end of B Use[B] set of expressions b+c computed in B with no prior definition of b or c Def[B] set of expression b+c for which either b or c is defined in block B prior to computation of b+c In[B] = out[B] - def[B] use[B]

out[B] = in[S] where S is successor of B An expression is VBE coming into a block if either it is used in B or it is live coming out and not defined in B An expression is VBE coming out of a block if it is live going into all the successors of B Initialization: in[B] = U for all B

Common Sub-expression Elimination

For every statement s of the form x=y+z such that y+z is available at the beginning of the block and y and z are not re-defined prior to s

  1. Find all definitions which have y+z that reach s’ block
  2. Create a new variable u
  3. Replace each w=y+z found in (1) by u=y+z; w=u
  4. Replace statement s by x=u

Module 15: Reaching Definition

Lecture 30: Analysis

Elimination of Induction Variable

A variable X is called induction variable of a loop if in every iteration value of X is changed by a constant value. Basic induction variables: as defined i=i ± c Secondary induction variable: a basic function of basic induction variable

Module 15: Reaching Definition

Lecture 30: Analysis

Detection of Induction Variables

Input: A loop L with reaching definition information and loop invariant computation information Output: A set of induction variables. Associated with each induction variable j is a triple (i, c, d) such that j=c*i+d. i is assumed to be basic induction variable, and j is said to belong to family of i.

  1. Find all basic induction variables of L (using loop invariant information). Each basic induction variable has a triple (i, 1, 0).
  2. Search for variable k with single assignment to k within L having one of the following forms: k=j*const, k=j/const, k=j ± const where j is an induction variable.
  3. If j is basic induction variable then k is in family of j. if j is not basic and is in family of i then There is no assignment to i between j and k No definition of j outside L reaches k
  4. Modify instructions computing induction variable such that ± are used rather than multiplication (strength reduction).

Strength Reduction

Consider each basic induction variable. For every induction variable j in family of i with triple (i, c, d)

  1. Create a new variable s
  2. Replace all assignments to j by j=s
  3. Immediately after each assignment i=i+n append s=s+c*n Place s in the family of i with triple (i,c,d)
  4. Initialize s to s=c*i+d in the pre-header Eliminate induction variables

Pointers

A := B + C

*P := D

F := *P

E := B+C

No definitions of B or C. Is B+C available at E := B+C depends whether *P changes B or C

Safe Assumption : Indirect assignment can change any variable, indirect use can use any name Therefore,

More live variable and reaching definitions than realistic. Fewer available expressions than realistic