(no title)
tirrex | 4 years ago
Although you can find these kind of examples for a few lines of code snippet, the question is what is the impact on overall program? Nowadays, I guess it has no impact for almost all programs. Because memory access patterns, system call overhead, operating system interaction etc. have much more impact on overall performance compared to optimizations enabled by undefined behaviors.
fooker|4 years ago
Optimizations directly enabled by Undefined behavior are only a very negligible part of the performance benefits of the existence of UB.
For example, consider the fact that array access out of bounds is UB. Because of this a compiler can assume (without proof) that all accesses are actually going to be in range. This enables a boatload of loop optimizations.
All non trivial optimizations done by a compiler usually assume such facts.
AlotOfReading|4 years ago
It's a complete disaster on all sides.
jcelerier|4 years ago
In most media apps, the actually processing intensive part definitely does not do syscalls or OS interaction. It's pure computations for as long as possible (and often non-parallelizable, e.g. x[i] *= x[i-1] sort of things). Disabling those optimisations is a killer.
foota|4 years ago