Compilers

Which is a characteristic of an IR in SSA form?

  1. AEach variable is assigned exactly once in the program
  2. BAll variables are placed in memory rather than registers
  3. CIt is rewritten so it contains no conditional branches at all
Show answer and explanation

Answer: A. Each variable is assigned exactly once in the program

In SSA form, variables are renamed so each is assigned only once, and φ functions select values at join points. If x is assigned twice, for example, it is split into x1 and x2, making clear which one each use refers to. The clear definition-use relationships make optimizations such as constant propagation and dead-code elimination easier. Branches are handled with φ functions, so branch instructions do not disappear. Variables are not forced into memory; most are treated as register candidates.

  • A. Correct. Variables are renamed so each is assigned once.
  • B. It is not a form that places variables in memory.
  • C. Branches remain; join points are handled with φ functions.
Practice this topic Back to topic

More Compilers questions

  1. Converting the code above to SSA form inserts an expression like "x3 = φ(x1, x2)" after the if statement. What does the φ function do?
  2. Which is an example of constant folding by a compiler?
  3. After repeatedly applying constant propagation and constant folding to the code above, what does it finally become?
  4. Which describes applying common subexpression elimination to the code above?
  5. What does dead-code elimination remove?