[libcxx] r350936 - [libcxx] Call __count_bool_true for bitset count

Adhemerval Zanella adhemerval.zanella at linaro.org
Fri Jan 11 09:31:17 PST 2019


Author: azanella
Date: Fri Jan 11 09:31:17 2019
New Revision: 350936

URL: http://llvm.org/viewvc/llvm-project?rev=350936&view=rev
Log:
[libcxx] Call __count_bool_true for bitset count

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).

It is mainly to help llvm inliner to generate better code for std::bitset
count for aarch64. It helps on both runtime and code size, since if inline
decides that _VSTD::count should not be inlined the vectorization will
create both aligned and unaligned variants (which add both code size and
runtime costs)


Modified:
    libcxx/trunk/include/bitset

Modified: libcxx/trunk/include/bitset
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?rev=350936&r1=350935&r2=350936&view=diff
==============================================================================
--- libcxx/trunk/include/bitset (original)
+++ libcxx/trunk/include/bitset Fri Jan 11 09:31:17 2019
@@ -991,7 +991,7 @@ inline
 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>(__count_bool_true(base::__make_iter(0), _Size));
 }
 
 template <size_t _Size>




More information about the libcxx-commits mailing list