SIMD instructions lowering CPU frequency

On Intel chips, the frequency impact and the specific frequency transition behavior depends on both the width of the operation and the specific instruction used. As far as instruction-related frequency limits go, there are three frequency levels – so-called licenses – from fastest to slowest: L0, L1 and L2. L0 is the “nominal” speed you’ll …

Read more

Do compilers take advantage of the indeterminate sequencing of function arguments?

It depends on the argument type, the called function’s calling convention, the archtecture and the compiler. On an x86, the Pascal calling convention evaluates arguments left to right whereas in the C calling convention (__cdecl) it is right to left. Most programs which run on multiple platforms do take into account the calling conventions to …

Read more

Should I use const for local variables for better code optimization? [duplicate]

Or am I wrong, and compilers can figure out by themselves that the local variable is never modified? Most of the compilers are smart enough to figure this out themselves. You should rather use const for ensuring const-correctness and not for micro-optimization. const correctness lets compiler help you guard against making honest mistakes, so you …

Read more

Does C/C++ offer any guarantee on minimal execution time?

No, time spent does not count as observable behaviour to be protected by the as-if rule: [C++14: 1.8/5]: A conforming implementation executing a well-formed program shall produce the same observable behavior as one of the possible executions of the corresponding instance of the abstract machine with the same program and the same input. However, if …

Read more

Reverse iterator returns garbage when optimized

Looking at std::reverse_iterator‘s libstdc++ implementation reveals something interesting: /** * @return A reference to the value at @c –current * * This requires that @c –current is dereferenceable. * * @warning This implementation requires that for an iterator of the * underlying iterator type, @c x, a reference obtained by * @c *x remains valid …

Read more