Skip to content

Commit 287cf99

Browse files
author
Allan Sandfeld Jensen
committed
Avoid SSE4/AVX instructions on Windows
The __popcnt intrinsics expand to SSE4+ instructions. Fixes: QTBUG-123811 Change-Id: If406bb88bd96263aefd23769bc779b49b9b4e72b Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/593284 Reviewed-by: Peter Varga <[email protected]>
1 parent a8ae455 commit 287cf99

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

chromium/base/allocator/partition_allocator/src/partition_alloc/starscan/state_bitmap.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,7 @@ StateBitmap<PageSize, PageAlignment, AllocationAlignment>::Quarantine(
235235
auto& cell = AsAtomicCell(cell_index);
236236
const CellType cell_before = cell.fetch_and(mask, std::memory_order_relaxed);
237237
// Check if the previous state was also quarantined.
238-
#if defined(_MSC_VER)
239-
return __popcnt64(
240-
#else
241-
return __builtin_popcount(
242-
#endif
238+
return std::popcount(
243239
static_cast<unsigned>((cell_before >> object_bit) &
244240
kStateMask)) != 1;
245241
}

chromium/third_party/blink/renderer/core/dom/element_rare_data_vector.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
3535
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
3636

37+
#include <bit>
38+
3739
namespace blink {
3840

3941
ElementRareDataVector::ElementRareDataVector() = default;
@@ -45,13 +47,8 @@ ElementRareDataVector::~ElementRareDataVector() {
4547
unsigned ElementRareDataVector::GetFieldIndex(FieldId field_id) const {
4648
unsigned field_id_int = static_cast<unsigned>(field_id);
4749
DCHECK(fields_bitfield_ & (static_cast<BitfieldType>(1) << field_id_int));
48-
#ifdef _MSC_VER
49-
return __popcnt(fields_bitfield_ &
50-
~(~static_cast<BitfieldType>(0) << field_id_int));
51-
#else
52-
return __builtin_popcount(fields_bitfield_ &
53-
~(~static_cast<BitfieldType>(0) << field_id_int));
54-
#endif
50+
return std::popcount(fields_bitfield_ &
51+
~(~static_cast<BitfieldType>(0) << field_id_int));
5552
}
5653

5754
ElementRareDataField* ElementRareDataVector::GetField(FieldId field_id) const {

chromium/third_party/blink/renderer/core/paint/sparse_vector.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <stdint.h>
99

10+
#include <bit>
1011
#include <limits>
1112
#include <type_traits>
1213

@@ -113,11 +114,7 @@ class CORE_EXPORT SparseVector {
113114
// Then count the total population of field IDs lower than that one we
114115
// are looking for. The target field ID should be located at the index of
115116
// of the total population.
116-
#ifdef _MSC_VER
117-
return __popcnt64(fields_bitfield_ & mask);
118-
#else
119-
return __builtin_popcountll(fields_bitfield_ & mask);
120-
#endif
117+
return std::popcount(fields_bitfield_ & mask);
121118
}
122119

123120
Vector<FieldType> fields_;

chromium/third_party/pdfium/third_party/libopenjpeg/ht_dec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static OPJ_BOOL only_cleanup_pass_is_decoded = OPJ_FALSE;
6969
static INLINE
7070
OPJ_UINT32 population_count(OPJ_UINT32 val)
7171
{
72-
#if defined(OPJ_COMPILER_MSVC) && (defined(_M_IX86) || defined(_M_AMD64))
72+
#if defined(OPJ_COMPILER_MSVC) && (defined(_M_AMD64) || defined(_M_IX86)) && (defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__))
7373
return (OPJ_UINT32)__popcnt(val);
7474
#elif (defined OPJ_COMPILER_GNUC)
7575
return (OPJ_UINT32)__builtin_popcount(val);

chromium/third_party/perfetto/include/perfetto/base/compiler.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@
7676

7777
#if defined(__GNUC__) || defined(__clang__)
7878
#define PERFETTO_POPCOUNT(x) __builtin_popcountll(x)
79-
#else
79+
#elif defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__)
8080
#include <intrin.h>
8181
#define PERFETTO_POPCOUNT(x) __popcnt64(x)
82+
#else
83+
#include <bit>
84+
#define PERFETTO_POPCOUNT(x) std::popcount(x)
8285
#endif
8386

8487
#if defined(__clang__)

0 commit comments

Comments
 (0)