lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Mon, Nov 23, 2020 at 8:53 AM Will Crowder <> wrote:
> Back when C really was just "the greatest macroassembler ever written," code-level micro-optimizations made sense.  But compiler technology has come a long way since then.

I remember when you could predict the code generated by the original
PDP-11 C compiler on the 7th edition Unix system. Adding "register"
variables and using post-increment or pre-decrement on pointers could
really speed up your code. That's no longer the case, the compiler
often has a better grasp on the behavior of modern CPUs than the
programmer. You can 'optimize' your code only to find that you added
dependencies between instructions that lead to more pipeline stalls or
that the "optimized" code grew the data structure beyond your cache
size, leading to lots of cache misses. An optimization for one
architecture can make things worse on another as well.