But would be surprised that a LLVM compiler with a custom-designed heuristic for specific optimizations cant manage this.
These problems may be polynomial etc etc, but MOST of the code generated should follow common patterns
I will have to give this some thought.
Thanks for the reply (also GP)
Most serious JIT engines do! For example V8, LuaJIT, Graal, C2.
> But would be surprised that a LLVM compiler with a custom-designed heuristic for specific optimizations cant manage this.
Rubinius for example tried writing custom optimisations like you're describing and didn't get very far. LLVM is not designed for these kind of optimisations - it understands memory reads and writes, not high-level semantic information about arrays and objects.
In practice, it just doesn't seem to work.
As I say I think it's a bare minimum for making a dynamic language genuinely fast. I gave a lecture about this https://www.youtube.com/watch?v=b1NTaVQPt1E.