Rate This Document
Findability
Accuracy
Completeness
Readability

Summary

When writing code, consider not only the optimization of assembly instructions, but also the impact of pipeline orchestration on performance. During pipeline orchestration, minimize interlocking. CPUs can work well in most cases, and the compiler has been optimized for out-of-order processors for nearly two decades. When instructions and data are executed in sequence, CPUs can yield the best performance.

So, use simple code. Simple code helps the optimization engine of the compiler identify and optimize the code. Try not to use jump instructions. When you have to, try to jump to the same direction each time. Complex designs, such as dynamic jump tables, do have powerful functions, but neither the processor nor the compiler can perform good prediction processing. Therefore, complex code is likely to cause pipeline pauses and guess errors. As a result, the performance of the processor is greatly affected.

Second, use simple data structures. Keeping data sequential, contiguous, and continuous prevents data pauses. Using the correct data structure and data distribution can greatly improve performance. As long as the code and data structures are as simple as possible, you can leave the rest of the work to the compiler's optimization engine.