C++20 introduces many new functions such as std::popcount
, I use the same functionality using an Intel Intrinsic.
I compiled both options - can be seen in Compiler Explorer code:
- Using Intel's AVX2 intrinsic
- Using std::popcount and GCC compiler flag "-mavx2"
It looks like the generated assembly code is the same, besides of the type checks used in std's template.
In terms of OS agnostic code and having the same optimizations -
Is it right to assume that using std::popcount
and the apt compiler vector optimization flags is better than directly using intrinsics?
Thanks.