4 ms·
Why? The intrinsics aren't portable, the other code is.
by bigcheesegs 9y ago
Why? The intrinsics aren't portable, the other code is.
- dpwm 9y agoEven with intrinsics that do have a degree of portability, I prefer the more explicit form of the bit counting just for readability. Nobody has to learn what popcnt means. These optimizations really mean that as software writers we can declare our intent and have the compiler do safe optimizations. It seems like these optimizations of Clang are also quite insensitive to the many different ways of writing the same thing that C++ has earned notoriety for.
- mpweiher 9y ago> I prefer the more explicit form Huh? It's not explicit, the purpose is implicit. You are writing down an algorithm that implements a popcount algorithm. The compiler than has to infer the fact that you actually wanted popcount (maybe you just wanted to waste a bit of time in a timing loop?) and then substitute something based on that inference. I am all for it being explicit, i.e. some library function that has a name that somewhere mentions "popcount" or some such. Then have the compiler generate whatever code it needs for that function.