3 ms·
I think some people misunderstand how compiler optimizations work. it's not magic, which makes each piece of code faster, it's just a bunch of deterministic cod
by Panzerschrek 1y ago
I think some people misunderstand how compiler optimizations work. it's not magic, which makes each piece of code faster, it's just a bunch of deterministic code transformation rules, which usually make code faster (considering large set of use-cases), but it's not proven that they always do so. So, by writing performant code one should always keep this in mind.
- Someone 1y agoThere are many optimizations that are guaranteed to make code run faster, but even then, that does not mean you should use them. There can be competition between optimizations. At a given moment, the preconditions for both optimization O1 and optimization O2 may hold, but if you then apply O1, the precondition for O2 may no longer hold and vice versa. In such cases, the best solution is to pick the better of O1 and O2.
- Findecanor 1y agoIf I understood it right, Equality Saturation of E-graphs is intended to help solve that problem. Cranelift has an optimiser based on it, for classic optimisations within an IR.
- account42 1y agoOne could even say that compiler optimizations are a set of deterministic code transformation rules that happen to make SPEC run faster. But programmers are not wrong to expect better from their compilers.