Skip to content

Commit

Permalink
[release/8.0] disable optimizations for PopCount (#99832) (#99926)
Browse files Browse the repository at this point in the history
* disable optimizations for PopCount

avoid using an optimization which might fail on non-SSE4 cpus.

* remove whitespace for jit-format

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Manish Godse <61718172+mangod9@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 18, 2024
1 parent 86f0444 commit fd8f5b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,11 @@ uint32_t BitOperations::Log2(uint64_t value)
// Return Value:
// The population count (number of bits set) of value
//
#if defined(_MSC_VER)
// Disable optimizations for PopCount to avoid the compiler from generating intrinsics
// not supported on all platforms.
#pragma optimize("", off)
#endif // _MSC_VER
uint32_t BitOperations::PopCount(uint32_t value)
{
#if defined(_MSC_VER)
Expand Down Expand Up @@ -3244,6 +3249,9 @@ uint32_t BitOperations::PopCount(uint64_t value)
return static_cast<uint32_t>(result);
#endif
}
#if defined(_MSC_VER)
#pragma optimize("", on)
#endif // _MSC_VER

//------------------------------------------------------------------------
// BitOperations::ReverseBits: Reverses the bits in an integer value
Expand Down

0 comments on commit fd8f5b5

Please sign in to comment.