All Exams Test series for 1 year @ ₹349 only
Question

Consider the control flow graph given below.



Which one of the following options is the set of live variables at the exit point of each basic block?

The correct answer is
B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:$\emptyset$

The problem requires identifying the set of live variables at the exit point of each basic block in a control flow graph. Let's analyze each block step-by-step:

  1. Basic Block B4:
    • The formula for \(g\) is \(g = d + e\).
    • At the exit of B4, no successors need any variables; hence, it's an empty set.
  2. Basic Block B3:
    • The formula for \(e\) is \(e = a + f\).
    • At the exit, we check the needs of B2 and B4. B2 uses \(d\) and \(e\), B4 uses \(d\) and \(e\).
    • Thus, variables \(b, c, e, f\) are needed at the exit of B3 to supply B2 and B4 correctly.
  3. Basic Block B2:
    • The formula for \(d\) is \(d = a + e\).
    • At the exit of B2, \(d\) and \(e\) must still be live for B4.
  4. Basic Block B1:
    • The formula for \(a\) is \(a = b + c\).
    • At the exit, variables \(a, b, c, e, f\) are needed as they are used or defined in subsequent blocks (B2 and B3).

The correct answer is: B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:\(\emptyset\)

Was this answer helpful?

Important Questions from Code Optimization

  1. Which of the following is the correct High level code for the given TAC in the passage
  2. What are the various LEADERS (leading statements) for the TAC given in the passage?
  3. Which of the followings is the correct Flow graph for the TAC given in the passage?
  4. Which of the following is the Optimized version for the given TAC in the passage
  5. Consider the control flow graph shown in the figure.
     


    Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B4 and B5?
    Note: All the variables are integers.

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App