Which expressions a compiler really optimises
Summary
Ridiculous Fish uses concrete machine code to examine which seemingly expensive calculations modern compilers simplify and where assumptions fail. Optimisation is only correct if it preserves all observable language rules. Micro-optimisations age faster than readable code and solid measurements.
Ideas
- Constant expressions can disappear completely during compilation.
- Algebraic simplifications depend on the language, overflow rules and floating-point semantics.
- The generated assembly code answers optimisation questions more reliably than intuition.
Recommendations
- Check claims about compilers with optimised assembly and realistic benchmarks.
- Write clear code first and only optimise measured bottlenecks.
References
Links to the original source and the Web Archive open in a new tab.