Static single-assignment form is an intermediate representation in which each named value has one static definition. Repeated source assignments receive different names:
x=1; x=x+2 becomes definitions such as x1=1; x2=x1+2. This makes def-use relationships explicit without requiring a search backward for which assignment supplied a value.At a join in a control-flow graph, a phi node selects the value associated with the edge actually taken. If one branch defines
x1=1 and another defines x2=2, the join defines x3=phi(x1,left; x2,right). The node selects an incoming value, not their arithmetic average. Loop-carried values similarly use entry and back-edge arguments. LLVM specifies that phi instructions occur first in a basic block, with an incoming value for each predecessor.[ref] Static uniqueness concerns program definitions, not the number of times a loop instruction executes.A phi node supplies the value at a join in static single-assignment form by selecting among values associated with incoming edges. In LLVM, it lists a value and predecessor basic block for each incoming edge, and phi nodes occur before ordinary operations in their block.[ref]
For example, if the left branch defines
x1=10 and the right defines x2=20, the join can define x3=phi(x1,left; x2,right). Arriving from the left gives ten; arriving from the right gives twenty. It does not average the arguments or evaluate both branches. At a loop header, another phi node can select an initial value on first entry and the updated value on later iterations. The node has one static definition even though its selected value can change across executions. Articles by others on the same topic
There are currently no matching articles.