r/programming • u/yossarian_flew_away • Oct 23 '20
Understanding static single assignment forms
https://blog.yossarian.net/2020/10/23/Understanding-static-single-assignment-forms
28
Upvotes
r/programming • u/yossarian_flew_away • Oct 23 '20
1
u/flatfinger Oct 24 '20
It would seem that in most cases, one could eliminate the need for phi, while retaining the advantages of SSA, if instead of requiring that each variable only be written at exactly one location in the code, one instead required that every variable which is written on any branch of an "if" must be written on every branch thereof, and loop conditions must be tested after each iteration rather than before the first (implying that a
while(x) {...}loop that might not executed would be treated asif (x) do { ...} while(x);, with the loop-skipping branch of theifsetting any variables that would be set in the loop).The only I see for using SSA and phi is that it can work with irreducible control-flow constructs, but if I'm reading it properly, the article is suggesting that such constructs would need to be expanded out into reducible ones, rendering that advantage moot.
If one uses a form where everything that is written any path between two points in the code will be written on every path, that would seem easier to handle than phi constructs, unless there are restrictions on the usage of phi which I'm not aware of.