[Bug libstdc++/113807] [performance] bitset::set not using memset opportunity

2024-02-15 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113807

--- Comment #8 from rhalbersma  ---
For bitset::operator==, I wonder why (at last in C++20 and later mode) it is
not defaulted? 

For bitset::set and bitset::operator==, I also wonder why the manual loop vs
memset/memcmp consteval logic is not delegated to a call of std::fill_n or
std::equal, respectively? Then std::bitset is better proofed against future
changes in the tradeoffs between manual loops, unrolled loops or library calls,
no?

[Bug libstdc++/113807] [performance] bitset::set not using memset opportunity

2024-02-15 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113807

--- Comment #3 from rhalbersma  ---
Nice that this is changed now. I noticed a similar optimization could be done
for bitset::operator== (more accurately: the helper _M_is_equal) where there is
an opportunity to use memcmp, with a similar dance for consteval contexts. MSVC
STL also does this.

[Bug libstdc++/113807] New: [performance] bitset::set not using memset opportunity

2024-02-07 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113807

Bug ID: 113807
   Summary: [performance] bitset::set not using memset opportunity
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rhalbersma at gmail dot com
  Target Milestone: ---

Conditionally on is_constant_evaluated() being false, bitset::reset delegate to
__builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)) and uses a loop otherwise. In
contrast, bitset::set unconditionally has a raw loop. 

Can't bitset::set also not similarly use __builtin_memset(_M_w, 0xFF, _Nw *
sizeof(_WordT)); when is_constant_evaluated() is false?

[Bug libstdc++/113806] New: [performance] bitset::operator>>= unnecessarily sanitizes the high-word

2024-02-07 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113806

Bug ID: 113806
   Summary: [performance] bitset::operator>>= unnecessarily
sanitizes the high-word
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rhalbersma at gmail dot com
  Target Milestone: ---

It seems that since time immemorial, bitset::operator>>= unnecessarily
sanitizes the high word by calling this->_M_do_sanitize(); 

It is unnecessary since right-shifting moves bits away from the high-word so
that the class invariant can not be violated (in contrast to
bitset::operator<<= where bits flow into the high word, and where t). 

Current LOC is 1092 in  on libstdc++ trunk, and could be removed with
no functional change.

[Bug libstdc++/108260] New: __cpp_lib_ranges_zip feature test macro not defined while std::views::zip is supported

2023-01-01 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108260

Bug ID: 108260
   Summary: __cpp_lib_ranges_zip feature test macro not defined
while std::views::zip is supported
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rhalbersma at gmail dot com
  Target Milestone: ---

I'm a happy user of std::views::zip in gcc-latest but AFAICS the feature test
macro __cpp_lib_ranges_zip is not yet defined, neither in , ,
, nor in . This makes it hard #ifdedf my code on this
feature. 

Just for my curiosity: is it generally the case that feature test macros are
being added along with the feature completeness? Or should I condition my mixed
C++20/C++23 code in another way?

[Bug c++/93480] Defaulted <=> doesn't expand array elements

2022-12-26 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93480

--- Comment #9 from rhalbersma  ---
Could this fix also be back-ported to gcc 10?

[Bug c++/94924] Default equality operator for C-array compares addresses, not data

2022-12-26 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94924

--- Comment #4 from rhalbersma  ---
Is there any chance that this bug fix can be backported to gcc 10 also?

[Bug c++/108214] New: writinng bitset to stringstream fails

2022-12-23 Thread rhalbersma at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108214

Bug ID: 108214
   Summary: writinng bitset to stringstream fails
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rhalbersma at gmail dot com
  Target Milestone: ---

#include 
#include 

int main() {
using T = std::bitset<1>;
T a(1);
T b;
std::stringstream sstr;
sstr << a;
sstr >> b;
}

The above program works correctly for g++ until version 12, but for version 13
(trunk) it errors out with: "terminate called after throwing an instance of
'std::invalid_argument' what():  bitset::_M_copy_from_ptr"

Godbolt link: https://godbolt.org/z/nnKT6cddb