CS Atlas GATE 2027
Compiler Design course
0 / 90 complete

Compiler Design/Phase 7 · Integration & Final Test

Chapter review LI.4.3 · Item 55 of 90

SSA form

Read at your own pace. Try the questions before opening the answers.

On this page

ACompressed recap

🧾

In SSA form every variable is assigned exactly once in the program text: each assignment creates a new version, each use names the version that reaches it, and φ-functions merge versions at join points. In straight-line code the number of names is the number of assignments plus the read-only variables.

BMerged rule card

4.3 Static single assignment (SSA) form; counting variables and temporaries

  • SSA: each variable assigned once in the text; versions x₁, x₂, ….
  • Straight-line: rename targets in order; uses take the latest version.
  • Joins: x₃ = φ(x₁, x₂) picks by incoming path; loop headers too.
  • Count = assignments + read-only variables.

CInterleaved GATE-style questions

Q1NAT2 marksCount

How many distinct names are in the SSA form of p = a + b; q = p − c; p = q * d; p = e − p; q = p + q?

Numerical answer: ________

Q2MCQ1 markRenaming

In SSA, the statement p = e − p (third assignment to p, previous version p₂) becomes:

  • (A) p₃ = e − p₃
  • (B) p₃ = e − p₂
  • (C) p₂ = e − p₂
  • (D) p = e − p₂

Q3MCQ1 markφ

In if (c) x = 1; else x = 2; print(x);, the SSA form needs:

  • (A) no φ
  • (B) one φ for x before print
  • (C) two φs
  • (D) a φ for c

Q4MSQ2 marksFacts

Which are true about SSA?

  • (A) It is a static property of the text.
  • (B) A variable assigned in a loop body has one SSA definition there.
  • (C) φ-functions are placed after every branch instruction.
  • (D) Many optimizing compilers use SSA as their IR.

Q5NAT1 markCount

Straight-line code with 6 assignments that reads 4 other variables (never assigned). How many names does its SSA form have?

Numerical answer: ________

Q6MCQ2 marksUse

Why does SSA help optimization?

  • (A) It removes all loops.
  • (B) Each use has exactly one definition, which is explicit.
  • (C) It shortens programs.
  • (D) It eliminates the need for registers.

Q7NAT1 markVersions

In x = 1; x = x + 1; x = x * 2; y = x, how many versions of x does SSA create?

Numerical answer: ________

Q8MCQ1 markPlacement

In a while loop that assigns i inside the body, a φ for i is placed:

  • (A) after the loop only
  • (B) at the loop header
  • (C) nowhere
  • (D) inside the body only

Answer Vault

Try the questions first. Open when you are ready to check.

Q1 Answer: 102 marks

5 assignments + 5 read-only variables (a, b, c, d, e) = 10.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q2 Answer: (B)1 mark

New version on the left, latest version on the right.

  • (A) is wrong: The use refers to the previous version.
  • (C) is wrong: The target needs a new version.
  • (D) is wrong: The target must be versioned.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q3 Answer: (B)1 mark

Two versions reach the print.

  • (A) is wrong: Two definitions reach the use.
  • (C) is wrong: One suffices.
  • (D) is wrong: c is not assigned in the branches.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q4 Answer: (A) (B) (D)2 marks

φ-functions go at joins, only where versions differ.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q5 Answer: 101 mark

6 versions + 4 read-only = 10.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q6 Answer: (B)2 marks

Definitions and uses are linked directly.

  • (A) is wrong: Loops remain.
  • (C) is wrong: It often adds φ-functions.
  • (D) is wrong: Registers are still needed.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q7 Answer: 31 mark

x₁, x₂, x₃: 3.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Q8 Answer: (B)1 mark

The header joins the entry path and the back path.

  • (A) is wrong: The header is the join.
  • (C) is wrong: Two definitions reach the header.
  • (D) is wrong: The join is at the header.

Re-read: Lesson 4.3 — Static single assignment (SSA) form; counting variables and temporaries

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.