On Thu, Jan 24, 2013 at 04:59:15AM +0100, Oleg Kuporosov wrote: > On Wednesday, 23 January 2013 at 21:14:26 UTC, Paulo Pinto wrote: > > >Many developers have no idea that modern CPUs do lots of things > >that invalidate the concept of C as a "high level assembler". > > > > Paolo, the most important features of C makes it "high-level > assembler" it are pointer and its arithmetics. What hell "modern CPUs" > doing wrong with it? [...]
For one thing, modern CPUs have pipelines and caches. Modern optimizing C compilers often rearrange instructions in order to maximize performance by reducing (or eliminating) pipeline hazards and cache misses. The resulting assembly code often look nothing like the source code. (In fact, some CPUs do this internally as well, and optimizing compilers often rearrange the code in order to take maximum advantage of what the CPU is doing.) The result of this is that many of the so-called "optimizations" that C programmers like to do by hand (and I am among them) actually have no real benefits, and in fact, sometimes has worse performance because it obscures your intent to the compiler, so the compiler is unable to produce the best code for it. T -- Ignorance is bliss... but only until you suffer the consequences!
