Skip to content

Centralize a couple JIT arithmetic helpers#127781

Merged
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:popcnt
May 6, 2026
Merged

Centralize a couple JIT arithmetic helpers#127781
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:popcnt

Conversation

@tannergooding
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 5, 2026 00:35
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 5, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors a few low-level JIT bit-manipulation helpers to use the shared BitOperations implementation instead of maintaining local counting/log2 helpers. It keeps the change scoped to internal helper code used by JIT bitsets and hash bit-vectors.

Changes:

  • Replaced hashbv’s local nearest_pow2 and word-popcount helpers with BitOperations::Log2/PopCount.
  • Replaced BitSetSupport::CountBitsInIntegral call sites in the UINT64 and ShortLong bitset implementations with BitOperations::PopCount.
  • Removed the now-unused BitSetSupport nibble-count table and integral bit-count helper implementation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/jit/hashbv.h Swaps nearest_pow2 over to BitOperations::Log2.
src/coreclr/jit/hashbv.cpp Replaces local hashbv popcount helpers with shared BitOperations::PopCount.
src/coreclr/jit/bitsetasuint64.h Uses shared popcount for the UINT64 bitset representation.
src/coreclr/jit/bitsetasshortlong.h Uses shared popcount for both short and long BSShortLong counting paths.
src/coreclr/jit/bitset.h Removes obsolete integral bit-count helper declarations.
src/coreclr/jit/bitset.cpp Removes obsolete nibble-count lookup table definition.

@tannergooding tannergooding marked this pull request as ready for review May 5, 2026 16:10
Copilot AI review requested due to automatic review settings May 5, 2026 16:10
@tannergooding
Copy link
Copy Markdown
Member Author

CC. @dotnet/jit-contrib, small cleanup as I noticed we had a couple remaining custom popcount algorithms, so I fixed them to just forward to the utils.h implementation instead.

There is a small annoying bit where size_t for Apple is neither uint32_t nor uint64_t (rather it is unsigned long, rather than unsigned int or unsigned long long) and is "ambiguous" between the two, but then it conflicts with them on other targets

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/jit/bitsetasuint64.h
Comment thread src/coreclr/jit/hashbv.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants