Something about IR Optimization
brrt-to-the-future.blogspot.com
brrt-to-the-future.blogspot.com
- Given that in this IR, every value has a single definition, and every use must reference that value, I'd argue that this is already SSA form.
- In fact, the concept of 'variable' is mostly missing, there's only a repeated reference to the same value. I think that simplifies things a lot, but maybe too much.
- Optimizing across expression boundaries is in fact very much the point, if we can keep the semantics the same.
Thanks for your interest!
> But it also means that the property we're interested in - a value is computed before it is used in, in all possible code flow paths - isn't really expressible by the IR.
...since you could verify that the blocks a value is used in are dominated by the block it's computed in.
In that IR the rule is that sharing cannot pass basic-block boundaries because of the exact kind of bug you indicate.
Isn't that what phi nodes were designed to fix?
This seems like a much weirder problem, in which the optimizer is unaware of control flow and so will allow a value to reference an instruction that does not dominate it.
LLVM's IR verifier ensures that instructions dominate all of their uses, which simply means that all users of an instruction must provably execute after that instruction. This verification step seems to be what's missing.
Anyways, seems to be some weird block scoping rules going on like with python.