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.

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.

Insights

  • Micro-optimisations age faster than readable code and solid measurements.

References

Read the original post

Search the Web Archive

Found a mistake or have something to add? Get in touch.