F i L:

> Oh you crazy compiler developers. Thinking everyone can read ASM 
> ;-)

I'd love to be able to develop compilers, but I am not that good yet :-)

Writing working asm is much simpler than writing efficient asm code (more 
efficient than compiler generated one, even for SIMD code where compilers are 
still quite bad). And reading asm is much simpler than writing it. And scanning 
asm code visually to look for simple things, is simpler than reading and 
understanding what each asm instruction does. Writing very efficient asm isn't 
a common skill today, but reading a bit of asm is something you learn in a 
matter of some days if you have the desire, the time, and the right books. Most 
asm does is simple arithmetic, updating some CPU flags, and moving variables 
from here to there, where most CPUs manage the cache levels transparently 
(manually managed Scratchpad cache memory us uncommon). Modern CPUs have 
accumulated tons of cruft, but at the base it's easy stuff.


> Though, there *could* be area 
> for automatic optimization here, right?

Currently DMD devs are mostly trying to fix bugs, instead of adding 
optimizations.

And as the pure attribute it's not just a matter of optimization. It's a 
contract between programmer and compiler. If you add "static" and then you use 
a variable in the enclosing function, you receive a compilation error. This 
error can't happen if "static-ness" is just an invisible automatic compiler 
optimization. It's good for such errors to come out, because when you use 
static you are stating you don't want to use outer function variables. So this 
is both a guaranteed optimization and a way to avoid using by mistake a 
variable defined in the enclosing scope. Using unwillingly variables from the 
outer scopes is a common source of bugs.

Bye,
bearophile

Reply via email to