Since .NET is a high level language it's not always possible to be sure what underlying instructions will be generated by the JIT.
Hardware intrinsics in .NET allow to access hardware specific instructions if we want to trade general-purpose of our code for
speed of specific hardware-backed instructions. In .NET those instructions and types are access from System.Runtime.Intrinsics and child namespaces.
Hardware intrinsics supports a variety of instructions. With one instruction, if our processor supports it, we can calculate the number of 1s with POPCNT in the value or perform our round od AES with _mm_aesdec_si128 backed by the hardware. And the list doesn't end there. Check the link for more instructions.
Docs 📑: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics?view=net-8.0
#dotnet #intrinsics #cpu #performance
---
If you find this useful, consider giving a like & share ❤.