<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/libcxx/include/__bit_reference, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[libc++] Replace __libcpp_{ctz, clz} with __builtin_{ctzg, clzg} (#133920)</title>
<updated>2025-04-19T00:57:05+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-04-19T00:57:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9e3982d9ae8173171cd7247ee505e9c02079c6bf'/>
<id>9e3982d9ae8173171cd7247ee505e9c02079c6bf</id>
<content type='text'>
`__libcpp_{ctz, clz}` were previously used as fallbacks for `__builtin_{ctzg, clzg}` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_{ctzg, clzg}` became available in Clang 19. Now that support for Clang 18 has been officially dropped in #130142, we can now safely  replace all instances of `__libcpp_{ctz, clz}` with `__count{l,r}_zero` (which internally call `__builtin_{ctzg, clzg}` and eliminate the fallback logic.

Closes #131179.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`__libcpp_{ctz, clz}` were previously used as fallbacks for `__builtin_{ctzg, clzg}` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_{ctzg, clzg}` became available in Clang 19. Now that support for Clang 18 has been officially dropped in #130142, we can now safely  replace all instances of `__libcpp_{ctz, clz}` with `__count{l,r}_zero` (which internally call `__builtin_{ctzg, clzg}` and eliminate the fallback logic.

Closes #131179.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Remove unnecessary division and modulo operations in bitset (#121312)</title>
<updated>2025-03-26T16:02:03+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-03-26T16:02:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=649cbcc3764c554c9c9839f021d073fa9a9f0515'/>
<id>649cbcc3764c554c9c9839f021d073fa9a9f0515</id>
<content type='text'>
The PR removes the unnecessary division and modulo operations in the
one-word specialization `__bitset&lt;1, _Size&gt;`. The reason is that for the
one-word specialization, we have `__pos &lt; __bits_per_word` (as
`__bitset&lt;1, _Size&gt;` is an implementation detail only used by the public
`bitset`). So `__pos / __bits_per_word == 0` and `__pos / __pos %
__bits_per_word == __pos`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The PR removes the unnecessary division and modulo operations in the
one-word specialization `__bitset&lt;1, _Size&gt;`. The reason is that for the
one-word specialization, we have `__pos &lt; __bits_per_word` (as
`__bitset&lt;1, _Size&gt;` is an implementation detail only used by the public
`bitset`). So `__pos / __bits_per_word == 0` and `__pos / __pos %
__bits_per_word == __pos`.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Fix {std, ranges}::equal for vector&lt;bool&gt; with small storage types (#130394)</title>
<updated>2025-03-19T15:51:21+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-03-19T15:51:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c5195ae2d0c1f3925f48ecb0cf037d3f67d45a85'/>
<id>c5195ae2d0c1f3925f48ecb0cf037d3f67d45a85</id>
<content type='text'>
The current implementation of `{std, ranges}::equal` fails to correctly
compare `vector&lt;bool&gt;`s when the underlying storage type is smaller than
`int` (e.g., `unsigned char`, `unsigned short`, `uint8_t` and
`uint16_t`). See [demo](https://godbolt.org/z/j4s87s6b3)). The problem
arises due to integral promotions on the intermediate bitwise
operations, leading to incorrect final equality comparison results. This
patch fixes the issue by ensuring that `{std, ranges}::equal` operate
properly for both aligned and unaligned bits.
 
Fixes #126369.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The current implementation of `{std, ranges}::equal` fails to correctly
compare `vector&lt;bool&gt;`s when the underlying storage type is smaller than
`int` (e.g., `unsigned char`, `unsigned short`, `uint8_t` and
`uint16_t`). See [demo](https://godbolt.org/z/j4s87s6b3)). The problem
arises due to integral promotions on the intermediate bitwise
operations, leading to incorrect final equality comparison results. This
patch fixes the issue by ensuring that `{std, ranges}::equal` operate
properly for both aligned and unaligned bits.
 
Fixes #126369.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Fix ambiguous call in {ranges, std}::find (#122641)</title>
<updated>2025-03-13T18:15:03+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-03-13T18:15:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3bd71cbec75292f188bee3aaba2dc94c8955ad66'/>
<id>3bd71cbec75292f188bee3aaba2dc94c8955ad66</id>
<content type='text'>
This PR fixes an ambiguous call encountered when using the `std::ranges::find` or `std::find`
algorithms with `vector&lt;bool&gt;` with small `allocator_traits::size_type`s, an issue reported
in #122528. The ambiguity arises from integral promotions during the internal bitwise
arithmetic of the `find` algorithms when applied to `vector&lt;bool&gt;` with small integral
`size_type`s. This leads to multiple viable candidates for small integral types:
__libcpp_ctz(unsigned), __libcpp_ctz(unsigned long), and __libcpp_ctz(unsigned long long),
none of which represent a single best viable match, resulting in an ambiguous call error.

To resolve this, we propose invoking an internal function __countr_zero as a dispatcher
that directs the call to the appropriate overload of __libcpp_ctz. Necessary amendments
have also been made to __countr_zero.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR fixes an ambiguous call encountered when using the `std::ranges::find` or `std::find`
algorithms with `vector&lt;bool&gt;` with small `allocator_traits::size_type`s, an issue reported
in #122528. The ambiguity arises from integral promotions during the internal bitwise
arithmetic of the `find` algorithms when applied to `vector&lt;bool&gt;` with small integral
`size_type`s. This leads to multiple viable candidates for small integral types:
__libcpp_ctz(unsigned), __libcpp_ctz(unsigned long), and __libcpp_ctz(unsigned long long),
none of which represent a single best viable match, resulting in an ambiguous call error.

To resolve this, we propose invoking an internal function __countr_zero as a dispatcher
that directs the call to the appropriate overload of __libcpp_ctz. Necessary amendments
have also been made to __countr_zero.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Optimize ranges::rotate for vector&lt;bool&gt;::iterator (#121168)</title>
<updated>2025-03-13T18:07:23+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-03-13T18:07:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4baf1c03fa949c0e6fd0a96f8b312cc5c152db5c'/>
<id>4baf1c03fa949c0e6fd0a96f8b312cc5c152db5c</id>
<content type='text'>
This PR optimizes the performance of `std::ranges::rotate` for
`vector&lt;bool&gt;::iterator`. The optimization yields a performance
improvement of up to 2096x.

Closes #64038.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR optimizes the performance of `std::ranges::rotate` for
`vector&lt;bool&gt;::iterator`. The optimization yields a performance
improvement of up to 2096x.

Closes #64038.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Optimize ranges::swap_ranges for vector&lt;bool&gt;::iterator (#121150)</title>
<updated>2025-03-04T22:15:36+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-03-04T22:15:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a12744ff05bbc2d0de711afb8b3a1c7a03a33914'/>
<id>a12744ff05bbc2d0de711afb8b3a1c7a03a33914</id>
<content type='text'>
This PR optimizes the performance of `std::ranges::swap_ranges` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.
The optimizations yield performance improvements of up to **611x** for
aligned range swap and **78x** for unaligned range swap comparison.
Additionally, comprehensive tests covering up to 4 storage words (256
bytes) with odd and even bit sizes are provided, which validate the
proposed optimizations in this patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR optimizes the performance of `std::ranges::swap_ranges` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.
The optimizations yield performance improvements of up to **611x** for
aligned range swap and **78x** for unaligned range swap comparison.
Additionally, comprehensive tests covering up to 4 storage words (256
bytes) with odd and even bit sizes are provided, which validate the
proposed optimizations in this patch.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Optimize ranges::equal for vector&lt;bool&gt;::iterator (#121084)</title>
<updated>2025-02-26T17:18:25+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-02-26T17:18:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7717a549e91c4fb554b78fce38e75b0147fb6cac'/>
<id>7717a549e91c4fb554b78fce38e75b0147fb6cac</id>
<content type='text'>
This PR optimizes the performance of `std::ranges::equal` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.
The optimizations yield performance improvements of up to 188x for
aligned equality comparison and 82x for unaligned equality
comparison. Moreover, comprehensive tests covering up to 4 storage words
(256 bytes) with odd and even bit sizes are provided, which validate the
proposed optimizations in this patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR optimizes the performance of `std::ranges::equal` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.
The optimizations yield performance improvements of up to 188x for
aligned equality comparison and 82x for unaligned equality
comparison. Moreover, comprehensive tests covering up to 4 storage words
(256 bytes) with odd and even bit sizes are provided, which validate the
proposed optimizations in this patch.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Optimize ranges::move{,_backward} for vector&lt;bool&gt;::iterator (#121109)</title>
<updated>2025-02-19T16:36:45+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-02-19T16:36:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ab3d793982acb946afc2028ca41304913879c6c9'/>
<id>ab3d793982acb946afc2028ca41304913879c6c9</id>
<content type='text'>
As a follow-up to #121013 (which optimized `ranges::copy`) and #121026
(which optimized `ranges::copy_backward`), this PR enhances the
performance of `std::ranges::{move, move_backward}` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.

The optimizations bring performance improvements analogous to those
achieved for the `{copy, copy_backward}` algorithms: up to 2000x for
aligned moves and 60x for unaligned moves. Moreover, comprehensive
tests covering up to 4 storage words (256 bytes) with odd and even bit
sizes are provided, which validate the proposed optimizations in this
patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As a follow-up to #121013 (which optimized `ranges::copy`) and #121026
(which optimized `ranges::copy_backward`), this PR enhances the
performance of `std::ranges::{move, move_backward}` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.

The optimizations bring performance improvements analogous to those
achieved for the `{copy, copy_backward}` algorithms: up to 2000x for
aligned moves and 60x for unaligned moves. Moreover, comprehensive
tests covering up to 4 storage words (256 bytes) with odd and even bit
sizes are provided, which validate the proposed optimizations in this
patch.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Fix UB in bitwise logic of {std, ranges}::{fill, fill_n} algorithms (#122410)</title>
<updated>2025-02-05T16:39:49+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-02-05T16:39:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cf9806eb4da23b42702aa88784969520702dae00'/>
<id>cf9806eb4da23b42702aa88784969520702dae00</id>
<content type='text'>
This PR addresses an undefined behavior that arises when using the
`std::fill` and `std::fill_n` algorithms, as well as their ranges
counterparts `ranges::fill` and `ranges::fill_n`, with `vector&lt;bool, Alloc&gt;`
that utilizes a custom-sized allocator with small integral types.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR addresses an undefined behavior that arises when using the
`std::fill` and `std::fill_n` algorithms, as well as their ranges
counterparts `ranges::fill` and `ranges::fill_n`, with `vector&lt;bool, Alloc&gt;`
that utilizes a custom-sized allocator with small integral types.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Optimize ranges::copy_backward for vector&lt;bool&gt;::iterator (#121026)</title>
<updated>2025-01-30T19:55:05+00:00</updated>
<author>
<name>Peng Liu</name>
<email>winner245@hotmail.com</email>
</author>
<published>2025-01-30T19:55:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=edc3dc6abd9dec70f03107d1477a2baffe7208f7'/>
<id>edc3dc6abd9dec70f03107d1477a2baffe7208f7</id>
<content type='text'>
As a follow-up to #121013 (which focused on `std::ranges::copy`), this
PR optimizes the performance of `std::ranges::copy_backward` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.
The optimizations yield performance improvements of up to 2000x for
aligned copies and 60x for unaligned copies.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As a follow-up to #121013 (which focused on `std::ranges::copy`), this
PR optimizes the performance of `std::ranges::copy_backward` for
`vector&lt;bool&gt;::iterator`, addressing a subtask outlined in issue #64038.
The optimizations yield performance improvements of up to 2000x for
aligned copies and 60x for unaligned copies.</pre>
</div>
</content>
</entry>
</feed>
