GateAI
Data Flow Analyses

GATE CSE 2015 Set 1 · Q50

MCQ2 marksMedium

Time

A variable xx is said to be live at a statement SiS_i in a program if the following three conditions hold simultaneously: i. There exists a statement SjS_j that uses xx ii. There is a path from SiS_i to SjS_j in the flow graph corresponding to the program iii. The path has no intervening assignment to xx including at SiS_i and SjS_j The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are

GATE CSE 2015 Set 1 Q50 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) r, u

Data Flow Analyses

A variable xx is live at statement SS if there is an execution path starting from SS along which xx is used before being redefined.

Let us analyze the statements in basic blocks 2 and 3:

  1. Basic Block 2 contains the statement v = r + u:

    • Variable rr is used in block 2 (and also in block 4: q = v + r), so rr is live at block 2.

    • Variable uu is used in block 2, so uu is live at block 2.

    • Variable ss is neither used in block 2 nor block 4, and is redefined in block 1 (s = p + q) before any use. Thus, ss is not live at block 2.

  2. Basic Block 3 contains the statement q = s * u:

    • Variable uu is used in block 3, so uu is live at block 3.

    • Variable ss is used in block 3, so ss is live at block 3.

    • Variable rr is used downstream in block 4 (q = v + r), and there is no assignment to rr between block 3 and block 4. Thus, rr is live at block 3.

Taking the intersection of variables live at block 2 and block 3:

{r,u}∩{r,s,u}={r,u}\{r, u\} \cap \{r, s, u\} = \{r, u\}

Hence, the variables live at both basic block 2 and basic block 3 are r,ur, u, matching option C.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Data Flow Analyses previous year question is Q50 of the GATE CSE 2015 Set 1 paper. Find more GATE CSE PYQs on Data Flow Analyses in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Data Flow Analyses PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Data Flow Analyses in GATE CSE

Data Flow Analyses has 8 GATE CSE PYQs across 8 papers from 2014 to 2026. 5 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2015 Set 1.

How GATE tests Data Flow Analyses

More from GATE CSE 2015 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2015 Set 1 · Q50 · MCQ

A variable x is said to be live at a statement Si in a program if the following three conditions hold simultaneously: i. There exists a statement Sj that uses x ii. There is a path from Si to Sj in the flow graph corresponding to the program iii. The path has no intervening assignment to x including at Si and Sj The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.