Consider the following intermediate program in three address code p = a − b q…

2017

Consider the following intermediate program in three address code

p = a − b
q = p c
p = u v
q = p + q

Which one of the following corresponds to a static single assignment from the above code?

  1. A.

    p₁ = a − b
    q₁ = p₁ c
    p₁ = u v
    q₁ = p₁ + q₁

  2. B.

    p₃ = a − b
    q₄ = p₃ c
    p₄ = u v
    q₅ = p₄ + q₄

  3. C.

    p₁ = a − b
    q₁ = p₂ c
    p₃ = u v
    q₂ = p₄ + q₃

  4. D.

    p₁ = a − b
    q₁ = p c
    p₂ = u v
    q₂ = p + q

Attempted by 38 students.

Show answer & explanation

Correct answer: B

Static Single Assignment form requires every variable to be assigned exactly once.

Each assignment creates a new version of the variable, typically denoted by subscripts.

In the given code, p and q are reassigned multiple times. Option B correctly assigns unique version numbers to each occurrence.

This satisfies the SSA constraint.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir