A huge number of languages are compiled into binar...
# thinking-together
y
A huge number of languages are compiled into binary code. Why solutions for binary code optimization didn't become so popular as LLVM and GCC?
The first thing that comes to mind is that each platform requires a different optimizer, but the optimization logic can be shared in some places.
m
what do you mean by binary optimization? most optimizations are done in previous phases in higher level representations like MLIR, SSA etc
y
I'm interested in a tool common to all languages.
m
binary is not common because you can have binaries for different architectures, at that level you lost that context
the lowest level you can optimize something is at the instruction level for each architecture, which is not common to all targets
that's why llvm exists, it's a low level instruction representation that can generate instructions for multiple architectures, everyone can contribute optimizations at that level and every language above and every architecture below benefits
y
This is initially clear. What specifically for x86-64?
m
which one, that's a family of processors all with different capabilities and subset of supported instructions 🙂
👍 1
y
Right. Although, as I have noticed, optimizers aimed at optimizing intermediate code turn out to be worse for a particular architecture.
m
yes, but optimizers for a particular architecture don't work for all the others 😄
🤷‍♂️ 1
you can solve that with a JIT
the JIT knows in which particular processor is running and can emit the best instructions for that processor
a
CPUs also do optimization at the instruction level to some extent. I think the reason that you see optimization happening at higher levels is that the levels are more expressive and easier to reason about abstractly which becomes harder after that information is lost.