Hacker Newsnew | past | comments | ask | show | jobs | submit | haqreu's commentslogin

nope, not mine

A full rewrite to the computer graphics course.


I removed it, no need to offend people with racial slur, especially when it is not intended.


What symbol was it talking about?


Hum. Did not anticipate that, thank you for pointing out.


I'd argue that Lengauer-Tarjan is overrated. While it is neat, it's premature optimization IMHO. Fully maximal SSA (at the entry of each block insert a phi-node for each variable) + dead code elimination (we need it anyways) is much simpler.


Typical implementations of Lengauer-Tarjan are often taken verbatim from Andrew Appel's book and involve higher constant factors than alternative algorithms - such as Cooper et al's "engineered" version of the usual fixpoint algorithm, which is very neat, simple, and performs well.

If you are saying that constructing SSA following the classical approach is a premature optimisation, perhaps you would prefer Braun et al's retelling of Cliff Click's SSA construction algorithm - which works backwards from uses to place phis and requires no dominance information to be computed.


Thank you for the reference, I'll check it.

Why not fully maximal SSA + DCE? I mean, other than timings consideration. Fully maximal does not even need any graph traversal, it is entirely local to each block.


I think it will introduce too many redundant phis, but I've never used it in practice - so I can only speculate. I'm not convinced DCE will clean maximal SSA up substantially. Even the classic Cytron et al algorithm must be combined with liveness analysis to avoid placing dead phis (that is, it does not produce pruned SSA by default). In the past, there was always a fear that SSA has the potential to cause quadratic blowup in the number of variables - this concern is mostly theoretical but probably influenced some of the design decision around algorithms for constructing SSA.

Braun et al's algorithm works backwards from uses (which generate liveness), so you get pruned SSA out. In the case of reducible control flow graphs, you also get minimal SSA. This is all without any liveness or dominance computation beforehand. Granted, you may want those things later, but it's nice that you can construct a decent quality SSA with a fairly intuitive algorithm. Also shown in the paper is that you can incorporate a few light optimisations during SSA construction (constant folding, for example).


I'll definitely test maximal SSA + DCE in tinyoptimizer when I'll get to it. For the moment I made [1] somewhat-pruned mem2reg pass, not even sure how to call it. But it indeed required to compute dominance frontiers.

[1] https://ssloy.github.io/tinyoptimizer/mem2reg/


Nice.

I'm always happy to see more accessible resources for compiler writers.

---

As an aside: for displaying CFGs on the page, it would be very interesting to emit something somewhat dynamic. SVGs are always a good start, but there is a neat library for doing hierarchical graph layout (dagre, with d3-dagre handling rendering as well). In my own efforts at pedagogy, I've been interested in producing CFGs in-browser whose basic blocks comprise a "unified diff" view of the block (this being achieved in realtime by maintaining a subset of LLVM whose CFGs are persistent). Then it is more obvious what has changed: at least in the case of mem2reg which shouldn't introduce new blocks or move too much around (I forget if it hoists allocas to the entry block or not).

It'd also be cool to distil what underlying ideas you have found to be most useful in your efforts. The constrained scope of them may be useful to me, as I've wanted to create a kind of "advent of compilers" for years (advent of code but with a heavy slant towards compiler tasks/algorithms).


Thank you!


The "week-end" part refers to the fact that I wrote it in one week-end with little to no experience in compiler design. You can check the commit history, 12 to 14 Jan, 2024 :)


I think the "week-end" reference up above was a little tongue in cheek, since the modern spelling is a compound word: https://linguix.com/english/common-mistake/week_end_hyphen

Not to take away from this awesome sharing.


Have you ever wondered how a compiler works, but you never found courage to find out? Then this series of articles is for you.


Here is the schematics:

https://hsto.org/webt/4a/mb/ad/4ambad_bocdk6_0khdqve6grzjs.p...

two ternary multiplexers out of two dg403 chips.


Fun!


Setun is the only example, and it had a binary memory.


There was also the Canadian QTC-1. [0]

[0] https://jglobal.jst.go.jp/en/detail?JGLOBAL_ID=2009020829793...


This is ROM only, not a fully functioning computer.


Head to the end of the paper about the ROM [0], and you'll find the QTC-1 was the computer said ROM was designed for, not the ROM design itself.

[0] https://wwwee.ee.bgu.ac.il/~kushnero/ternary/Using%20CMOS%20...


AFAIK it was never built, only partially designed.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: