3 ms·
Thanks for the feedback! You're right that, at least in LLVM, SSA form is tied inextricably to basic blocks (since phis encode their source blocks). However, t
by woodruffw 6y ago
Thanks for the feedback!
You're right that, at least in LLVM, SSA form is tied inextricably to basic blocks (since phis encode their source blocks). However, the theory of operation for SSA itself isn't tied to any particular control flow representation: it only stipulates the two rules mentioned in the post.
My goal with this post was to introduce SSA at a high level and show why it makes a few optimizations simpler, without requiring readers to understand the other parts of an optimizing compiler (like why we reduce the CFG's representation to a graph of basic blocks). It's why I chose to use pseudo-C for some of the SSA reduction examples, rather than LLVM IR. But I certainly understand that this approach doesn't work for everybody :-)
- dragontamer 6y agoI certainly appreciate the difficulty of choosing which subjects need to be explored: too many subjects and you become unfocused. Too few, and you run the risk of not providing a solid base to teach the subject matter. Its overall a good blogpost in any case. -------- One more "criticism" (but not really). > Rule #2: Whenever we need to choose a variable based on control flow, we use the Phi function (φ) to introduce a new variable based on our choice. You might actually benefit from a more complicated example here, rather than the simpler example you chose. A do-while loop: int x = 0; do{ x = x + 1; } while (x < 100); This has always been the hardest thing for me to understand, with respect to #2 and SSA in general. int x_0 = 0; do{ x_1 = phi(x_0, x_2); x_2 = x_1 + 1; } while (x_2 < 100); On the one hand: choosing simple-to-understand examples is helpful to the reader, because they're simpler to understand. On the other hand, smacking the reader with the most complex case may suddenly spur inspiration and the ability to understand the whole problem. I guess its a style choice. But something to think about...