Pregunta

Today I stumbled upon one simple part of code and I would like to know more people opinion. What would be the fastest code to evaluate this graph

¿Fue útil?

Solución

There is no such thing as the fastest code to evaluate this graph. It depends on the processor architecture. What can be faster on one architecture, will be slower on another, or not even possible.

Nowadays, the compilers excel at block optimizations, and you should write the code as natural as you can and let the compiler decide what "the fastest" means. If the compiler doesn't have an optimization option, the best way to handle this type of conditions is to use 'conditional move' instructions, because they do not stall the pipeline, but this is very much specific to certain architectures.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top