microsoft / microsoft/STL

`<bit>`: Should we query for SSE4.2 instead of AVX for `popcnt` instruction?

Open
#5,441 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

There's __check_arch_support intrinsic to check for features at compile time. Seems to be something new, haven't noticed until recently.

This allows checking for /arch:SSE4.2 at compile time.

We can use popcnt unconditionally in more cases than just __AVX__. But with will take bringing another intrinsic in. Do we want that?

The question is about compile-time unconditional activation; runtime query already checks for SSE4.2.

/arch:SSE4.2 is x64-only. It is the first option available above the SSE2 baseline.

DevCom-10664771 author claims, which I find interesting, but still don't care enough to verify, that:

Windows 11 requirements got bumped up from SSE4.1 to SSE4.2

So the /arch:SSE4.2 option may get some usage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing compile-time AVX guard for popcnt and compare it with the runtime SSE4.2 query described in the issue. Evaluate whether __check_arch_support can safely recognize /arch:SSE4.2 on x64, then document the decision and update the relevant compile-time handling if warranted.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.