Does phi function comply with static single assignment form?

Since SSA has two requirements:

  1. Every variable is assigned exactly once
  2. Every variable is defined before it is used

Phi function of a loop may be like this:

%indvars.iv = phi i64 [ 0, %entry ], [, %for.body ]

In this phi function, appears before it is generated. Does it violate SSA form?
In my opinion, it only appears before it is defined, but it is not used (in the first iteration) before it is generated and therefore this phi function complies with SSA form.
Is this explanation correct?

Yes, I think you’ve got the right idea. Another way to think of it is that uses in phi instructions are special because they are deemed to occur on an edge of the control flow graph. So as long as the definition of dominates the edge from %for.body to the current block, we are OK.

1 Like