GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 12

GATE CSE 2017 Set 1 Q12

Compiler Design · Intermediate Code · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q12 1 mark · MCQ
Report issue

Intermediate Code

Question 12, GATE 2017: Convert p=a−b; q=p*c; p=u*v; q=p+q to static single assignment form. Options: A p1=a−b;q1=p1*c;p1=u*v;q1=p1+q1. B p3=a−b;q4=p3*c;p4=u*v;q5=p4+q4. C p1=a−b;q1=p2*c;p3=u*v;q2=p4+q3. D p1=a−b;q1=p*c;p2=u*v;q2=p+q.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. SSA requires each defined variable version to have exactly one assignment. Subscripts need not start at 1, but every use must refer to the correct reaching definition.

2. First create p3=a−b; then q4=p3*c must use that version. The reassignment p=u*v needs a different version, p4.

3. The last sum uses new p and old q: q5=p4+q4. This is option B. A repeats definitions, C uses undefined versions, and D leaves unversioned references.

Original paper, page 7 · Answer key