GATE CS 2017 Set 1 — Question 12
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+1 / -0.33EasyThree-Address CodeIntermediate Code GenerationCompiler Design
Compiler Design → Intermediate Code Generation → Three-Address Code
Last updated
Question
Consider the following intermediate program in three address codeWhich one of the following corresponds to a static single assignment form of the above code?
p = a - b
q = p * c
p = u * v
q = p + q
Correct answer
(B) [code]
Solution
Static Single Assignment (SSA) form is an intermediate representation used in compilers where each variable is assigned exactly once, and every variable is defined before it is used.Original code:
1.
2.
3.
4.
To convert this to SSA, we must create a new version of a variable every time it is assigned. Let's trace the data flow:- Line 1: is assigned. Let's call this version . So, .
- Line 2: is assigned. Let's call this version . It uses the current value of , which is . So, .
- Line 3: is assigned again. We must use a new version, . So, .
- Line 4: is assigned again. We must use a new version, . It uses the current value of (from line 3, which is ) and the current value of (from line 2, which is ). So, .
- Option (A): and are assigned twice, which violates the fundamental rule of SSA.
- Option (B): Every assignment uses a unique variable name (). The data dependencies are correctly maintained: uses (the result of the first line), and uses (the result of the third line) and (the result of the second line). This is a valid SSA form.
- Option (C): Uses variables like and that are never defined in the code.
- Option (D): Uses unversioned variables and in the expressions, which is not allowed in SSA.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Intermediate Code Generation
2026 Set 2 Q17In C runtime environment, which one of the following is stored in heap?2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]2026 Set 1 Q28Which of the following statements is/are true?2026 Set 2 Q35A lexical analyzer uses the following token definitions - - …