NEW 197816
bitCount() should use popcount where available
https://bugs.webkit.org/show_bug.cgi?id=197816
Summary bitCount() should use popcount where available
Robin Morisset
Reported 2019-05-11 10:42:25 PDT
...
Attachments
Patch (1.44 KB, patch)
2019-05-11 10:44 PDT, Robin Morisset
sam: review-
ews-watchlist: commit-queue-
Archive of layout-test-results from ews212 for win-future (13.52 MB, application/zip)
2019-05-11 15:35 PDT, EWS Watchlist
no flags
Patch (8.55 KB, patch)
2019-05-13 15:39 PDT, Robin Morisset
ysuzuki: review-
ysuzuki: commit-queue-
Robin Morisset
Comment 1 2019-05-11 10:44:11 PDT
EWS Watchlist
Comment 2 2019-05-11 15:35:04 PDT
Comment on attachment 369653 [details] Patch Attachment 369653 [details] did not pass win-ews (win): Output: https://webkit-queues.webkit.org/results/12164598 New failing tests: js/dom/custom-constructors.html
EWS Watchlist
Comment 3 2019-05-11 15:35:06 PDT
Created attachment 369663 [details] Archive of layout-test-results from ews212 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews212 Port: win-future Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Sam Weinig
Comment 4 2019-05-11 16:49:00 PDT
Comment on attachment 369653 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=369653&action=review > Source/WTF/ChangeLog:9 > + * wtf/StdLibExtras.h: > + (WTF::bitCount): Do we have any tests for bitCount? Might be a good time to add one, make sure there is no weirdness around the edge cases (e.g. 0 and MAX_UINT). > Source/WTF/wtf/StdLibExtras.h:157 > +#if COMPILER(GCC_COMPATIBLE) The preferred way to do this would be to add a WTF_COMPILER_SUPPORTS_BUILTIN_POPCOUNT to Compiler.h, and then do a COMPILER_SUPPORTS(BUILTIN_POPCOUNT) check here. That way, if we ever change/add compilers, there is one place were we can define it's feature set.
Daniel Bates
Comment 5 2019-05-11 20:36:58 PDT
I could have sworn a group of us came up with a slightly more complete and maybe even optimal? impl. (Surprising right?) here: <https://bugs.webkit.org/attachment.cgi?id=350281&action=prettypatch> (bug# 189633). But I can’t remember if we proved it by dumping assembly. Can we use ^ that code?
Daniel Bates
Comment 6 2019-05-11 20:40:19 PDT
Eh, maybe the existing branch less one is still better when you don’t have the instruction. I don’t know.
Robin Morisset
Comment 7 2019-05-13 14:00:39 PDT
(In reply to Daniel Bates from comment #5) > I could have sworn a group of us came up with a slightly more complete and > maybe even optimal? impl. (Surprising right?) here: > <https://bugs.webkit.org/attachment.cgi?id=350281&action=prettypatch> (bug# > 189633). But I can’t remember if we proved it by dumping assembly. Can we > use ^ that code? Thanks for the pointer, I've reviewed that patch. I agree that these two patches are trying to do the same thing and should be merged.
Robin Morisset
Comment 8 2019-05-13 14:05:51 PDT
(In reply to Sam Weinig from comment #4) > Comment on attachment 369653 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=369653&action=review > > > Source/WTF/ChangeLog:9 > > + * wtf/StdLibExtras.h: > > + (WTF::bitCount): > > Do we have any tests for bitCount? Might be a good time to add one, make > sure there is no weirdness around the edge cases (e.g. 0 and MAX_UINT). I will do that. > > > Source/WTF/wtf/StdLibExtras.h:157 > > +#if COMPILER(GCC_COMPATIBLE) > > The preferred way to do this would be to add a > WTF_COMPILER_SUPPORTS_BUILTIN_POPCOUNT to Compiler.h, and then do a > COMPILER_SUPPORTS(BUILTIN_POPCOUNT) check here. That way, if we ever > change/add compilers, there is one place were we can define it's feature set. A difficulty here is that different compilers can have different syntaxes for builtins (e.g. __builtin_popcntll for Clang/GCC vs __popcnt64 for MSVC). So I am tempted to keep checking for specific compilers here. But at least I should replace GCC_COMPATIBLE (which is not what I thought) by GCC_OR_CLANG. I thought of supporting MSVC, but it is tricky because its __popcnt builtin is only valid on machines with the corresponding instruction (see my comment on https://bugs.webkit.org/show_bug.cgi?id=189633)
Robin Morisset
Comment 9 2019-05-13 15:39:48 PDT
Created attachment 369791 [details] Patch Added a test, and replaced GCC_COMPATIBLE by GCC_OR_CLANG.
Sam Weinig
Comment 10 2019-05-13 17:37:02 PDT
(In reply to Robin Morisset from comment #8) > (In reply to Sam Weinig from comment #4) > > > > > Source/WTF/wtf/StdLibExtras.h:157 > > > +#if COMPILER(GCC_COMPATIBLE) > > > > The preferred way to do this would be to add a > > WTF_COMPILER_SUPPORTS_BUILTIN_POPCOUNT to Compiler.h, and then do a > > COMPILER_SUPPORTS(BUILTIN_POPCOUNT) check here. That way, if we ever > > change/add compilers, there is one place were we can define it's feature set. > > A difficulty here is that different compilers can have different syntaxes > for builtins (e.g. __builtin_popcntll for Clang/GCC vs __popcnt64 for MSVC). I don't think that is a problem. Just make the defines WTF_COMPILER_SUPPORTS_BUILTIN_POPCOUNT/WTF_COMPILER_SUPPORTS_BUILTIN_POPCOUNTLL. Since the MSVC one is called __popcnt64, it won't be defined for MSVC.
Yusuke Suzuki
Comment 11 2020-06-12 20:03:10 PDT
Comment on attachment 369791 [details] Patch Looks like build is failing.
Note You need to log in before you can comment on or make changes to this bug.