It is said that when converting intermediate code to static single assignment form,
It is necessary to calculate the dominators of basic blocks
The somewhat obvious way to do this as a fixed point of equations is slow
To do it fast, you need to use the fairly complicated Lengauer-Tarjan algorithm
I can see the first two points, but I'm not clear about the reasoning behind the third. In particular, is there any reason why you can't do it just in the process of calculating the preorder dominator tree? I've implemented a version of that in JavaScript and it seems to work:
var domPreorder = [];
function doms(b) {
b.children = [];
for (var c of b[b.length - 1].targets)
if (c.i == null) {
c.i = domPreorder.length
domPreorder.push(c)
b.children.push(c)
c.parent = b
doms(c)
}
}
f[0].i = 0
domPreorder.push(f[0])
doms(f[0])
Is there some disadvantage to this method that I'm not seeing?