Machine Code

When you have a small piece of very hot code, it may be worth inspecting the generated machine code to see if it has any inefficiencies. The Compiler Explorer website is an excellent resource when doing this.

Relatedly, the core::arch module provides access to architecture-specific intrinsics, many of which relate to SIMD instructions.

It is sometimes possible to avoid bounds checking within loops by adding assertions on the ranges of the index variables. This is an advanced technique, and you should check the generated code to ensure the bounds checks are actually removed. Example 1, Example 2.