←back to thread

Why SSA Compilers?

(mcyoung.xyz)
158 points transpute | 8 comments | | HN request time: 0.31s | source | bottom
Show context
rdtsc ◴[] No.45674959[source]
I like the style of the blog but a minor nit I'd change is have a definition what SSA is right at the top. It discusses SSA for quite a while "SSA is a property of intermediate representations (IRs)", "it's frequently used" and only 10 paragraphs down actually defines what SSA is

> SSA stands for “static single assignment”, and was developed in the 80s as a way to enhance the existing three-argument code (where every statement is in the form x = y op z) so that every program was circuit-like, using a very similar procedure to the one described above.

I understand it's one of those "well if you don't know what it is, the post is not for you" but I think it's a nice article and could get people who are not familiar with the details interested in it

> The reason this works so well is because we took a function with mutation, and converted it into a combinatorial circuit, a type of digital logic circuit that has no state, and which is very easy to analyze.

That's an interesting insight, it made sense to me. I only dealt with SSA when decompiling bytecode or debugging compiler issues, and never knew why it was needed, but that sort of made it click.

replies(5): >>45675058 #>>45675212 #>>45676248 #>>45676424 #>>45679311 #
1. vidarh ◴[] No.45675058[source]
This post is frankly one of the most convoluted discussions of SSA I've read. There's lots of info there, but I'd frankly suggest going back and look at a paper on implementing it. I think I first came across SSA in a paper adding it to Wirths Oberon compiler, and it was much more accessible.

Edit: It was this paper by Brandis and Mössenböck: https://share.google/QNoV9G8yMBWQJqC82

replies(3): >>45675173 #>>45675544 #>>45675841 #
2. jhallenworld ◴[] No.45675173[source]
Also I recommend Bob Morgan's book:

https://turbo51.com/download/Building-an-Optimizing-Compile-...

replies(2): >>45675914 #>>45678582 #
3. jchw ◴[] No.45675544[source]
Honestly, I think it's just something you either like or don't. If all you were trying to do was understand SSA, I agree this blog post is probably inefficient at that particular task, but often blog posts are entertainment as much as education, so meandering through a bunch of different things along the way is part of the deal. Personally I thought there were a lot of pretty interesting insights that I haven't seen a lot of discussion about in other places, though I will admit I mostly learned about SSA from Wikipedia and from people yelling about compilers online.
4. Rochus ◴[] No.45675841[source]
Thanks for the link. Looks like an interesting paper. Here is the original reference: https://dl.acm.org/doi/10.1145/197320.197331.

And here is a better readable postscript version: https://web.archive.org/web/20170706013237/ftp://ftp.ssw.uni...

5. Rochus ◴[] No.45675914[source]
Indeed a great book; I even have a paper copy.

The SSA book is also pretty good: https://web.archive.org/web/20201111210448/https://ssabook.g...

replies(1): >>45676244 #
6. mananaysiempre ◴[] No.45676244{3}[source]
I’ve found the SSA book to be... unforgiving in its difficulty. Not in the sense that I thought it to be a bad book but rather in that I was getting the feeling that a dilettante in compilers like me wasn’t the target audience.
replies(1): >>45676301 #
7. Rochus ◴[] No.45676301{4}[source]
Like so many compiler books from academia.
8. penguin_booze ◴[] No.45678582[source]
This only contains the first 3 chapters.