Andrei Alexandrescu needs to read this
Walter Bright
newshound2 at digitalmars.com
Wed Oct 23 23:22:08 UTC 2019
On 10/23/2019 3:03 PM, Jonathan Marler wrote:
> What I find funny is that there are alot of clever tricks you can do to make
> your code execute less operations, but with modern CPUs it's more about making
> your code more predictable so that the cache can predict what to load next and
> which branches you're more likely to take. So in a way, as CPUs get smarter,
> you want to make your code "dumber" (i.e . more predictable) in order to get the
> best performance. When hardware was "dumber", it was better to make your code
> smarter. An odd switch in paradigms.
Keep in mind that starting in the late 70's, CPUs started being designed around
the way compilers generate code. (Before then, instruction sets were a wacky
collection of seemingly unrelated instructions. Compilers like orthogonality,
and specialized instructions to do things like stack frame setup / teardown.)
This means that unusual instruction sequences tend to perform less well than the
ordinary stuff a compiler generates.
It's also true that code optimizers are tuned to what the local C/C++ compiler
generates, even if the optimizer is designed to work with multiple diverse
languages.
More information about the Digitalmars-d
mailing list