In FFmpeg, we have found in the past that functions written in pure assembly are typically a few % faste than those written in intrinsics. Depending on your use case, that may make it worth it.
The obvious disadvantage is that pure assembly is harder, so writing functions takes a bit longer.
In my experience the behavior is stable i.e. doesn't often change between rebuilds (at least in VC++). I can manage this by looking at compiler's output: when I find there something I don't want, be it stack spilling or other reasons for me not liking the assembly, I go fix my C++ code.
> so writing functions takes a bit longer
Also reading is hard, therefore refactoring/improvements is hard, too. I have an impression the assembly is write only language.
This is less true when you try and support many versions of many compilers, however, in my experience.
Source: I've ported multiple assembly language games from one assembly language to another.
Local variables and function arguments are named, as opposed to xmm/ymm register numbers.
I can use (forcefully inlined) C++ functions to compose code from smaller pieces. In some cases, even OOP.
Even in vectorized code there’re pieces running on scalar blocks of cores: loops, addresses calculations, conditions. With assembly you have to use it for the whole things.
Or do you actually write separate asm for x86 and x86_64?
The idea behind intrinsics is that you use one, or several assembly instructions in your code base, letting the compiler manage registers for you. But (especially these days) there is rarely a single instruction that makes your code go faster: you have to write entire large blocks of assembly. That is much better done using assembly than intrinsics.
- codegen because the compiler spills better than you, and knows what register to save. It knows about register renaming
- inlining works better
- loop unrolling works better
- any kind of hoisting
And it's also 3x faster to write, and much faster to refactor back to C++. Provided you have the right backend, it will lead to less maintenance issue with about 5% better performance.