[PATCH] D69334: [MathExtras] Add intrinsic for the PopulationCounter in Visual Studio

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 05:48:05 PDT 2019


RKSimon added a reviewer: RKSimon.
RKSimon added a comment.

GCC's __builtin_popcnt guarantees fallback to generic code if the cpu doesn't support a CTPOP-style instruction, I'm not sure how many people build clang with -march=native (or whatever) but I'd expect most people to just build for generic x86_64, which means we're probably executing a slow generic path anyhow.

The MSVC popcnt intrinsics always generates a x86 POPCNT instruction and we can't assume that this is available - its annoying but I can guarantee that somebody out there is building/running on an old box (or VM) that will fail.

As Craig mentioned MSVC is awful at building with target cpu defines - its gotten better and defines __AVX__/__AVX2__ etc. more recently but that's a poor wrapper for checking whether POPCNT can be used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69334/new/

https://reviews.llvm.org/D69334





More information about the llvm-commits mailing list