WebKit Bugzilla
Attachment 369653 Details for
Bug 197816
: bitCount() should use popcount where available
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch197816 (text/plain), 1.44 KB, created by
Robin Morisset
on 2019-05-11 10:44:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Robin Morisset
Created:
2019-05-11 10:44:11 PDT
Size:
1.44 KB
patch
obsolete
>diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index a5f9d9680c2..94bb4bb505a 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,13 @@ >+2019-05-11 Robin Morisset <rmorisset@apple.com> >+ >+ bitCount() should use popcount where available >+ https://bugs.webkit.org/show_bug.cgi?id=197816 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/StdLibExtras.h: >+ (WTF::bitCount): >+ > 2019-05-10 Saam barati <sbarati@apple.com> > > Bag's move operator= leaks memory >diff --git a/Source/WTF/wtf/StdLibExtras.h b/Source/WTF/wtf/StdLibExtras.h >index 35ec44eb7ec..5a1a646d57a 100644 >--- a/Source/WTF/wtf/StdLibExtras.h >+++ b/Source/WTF/wtf/StdLibExtras.h >@@ -154,14 +154,22 @@ inline ToType safeCast(FromType value) > // Returns a count of the number of bits set in 'bits'. > inline size_t bitCount(unsigned bits) > { >+#if COMPILER(GCC_COMPATIBLE) >+ return __builtin_popcount(bits); >+#else > bits = bits - ((bits >> 1) & 0x55555555); > bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333); > return (((bits + (bits >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; >+#endif > } > > inline size_t bitCount(uint64_t bits) > { >+#if COMPILER(GCC_COMPATIBLE) >+ return __builtin_popcountll(bits); >+#else > return bitCount(static_cast<unsigned>(bits)) + bitCount(static_cast<unsigned>(bits >> 32)); >+#endif > } > > // Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
sam
:
review-
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197816
:
369653
|
369663
|
369791