[PATCH] D55427: [libcxx] Call __count_bool_true for bitset count

Adhemerval Zanella via Phabricator reviews at reviews.llvm.org
Mon Dec 10 05:29:28 PST 2018


zatrazz updated this revision to Diff 177489.
zatrazz retitled this revision from "[libcxx] Use specialized helper for __bit_reference count" to "[libcxx] Call __count_bool_true for bitset count".
zatrazz added a comment.

This patch aims to help clang with better information so it can inline
__bit_reference count function usage for both std::biset. Current clang
inliner can not infer that the passed typed will be used only to select
the optimized variant, it evaluates the type argument and type check as
a load plus compare (although later optimization phases correctly
optimized this out).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55427/new/

https://reviews.llvm.org/D55427

Files:
  include/bitset


Index: include/bitset
===================================================================
--- include/bitset
+++ include/bitset
@@ -991,7 +991,7 @@
 size_t
 bitset<_Size>::count() const _NOEXCEPT
 {
-    return static_cast<size_t>(_VSTD::count(base::__make_iter(0), base::__make_iter(_Size), true));
+    return static_cast<size_t>(_VSTD::__count_bool_true(base::__make_iter(0), _Size));
 }
 
 template <size_t _Size>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55427.177489.patch
Type: text/x-patch
Size: 418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181210/d6fba3e9/attachment.bin>


More information about the libcxx-commits mailing list