Skip to content

Commit 50c3c86

Browse files
[release/8.0-staging] disable optimizations for PopCount (#99832)
* disable optimizations for PopCount avoid using an optimization which might fail on non-SSE4 cpus. * remove whitespace for jit-format --------- Co-authored-by: Manish Godse <[email protected]>
1 parent e373424 commit 50c3c86

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/coreclr/jit/utils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,6 +3192,11 @@ uint32_t BitOperations::Log2(uint64_t value)
31923192
// Return Value:
31933193
// The population count (number of bits set) of value
31943194
//
3195+
#if defined(_MSC_VER)
3196+
// Disable optimizations for PopCount to avoid the compiler from generating intrinsics
3197+
// not supported on all platforms.
3198+
#pragma optimize("", off)
3199+
#endif // _MSC_VER
31953200
uint32_t BitOperations::PopCount(uint32_t value)
31963201
{
31973202
#if defined(_MSC_VER)
@@ -3244,6 +3249,9 @@ uint32_t BitOperations::PopCount(uint64_t value)
32443249
return static_cast<uint32_t>(result);
32453250
#endif
32463251
}
3252+
#if defined(_MSC_VER)
3253+
#pragma optimize("", on)
3254+
#endif // _MSC_VER
32473255

32483256
//------------------------------------------------------------------------
32493257
// BitOperations::ReverseBits: Reverses the bits in an integer value

0 commit comments

Comments
 (0)