https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128410

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Or perhaps try to recurse:
  if (__builtin_constant_p (__l) && !__builtin_constant_p (__x))
    {
      __x &= ((_Tp)1 << __l) - 1;
      return __x * bit_repeat(_Tp(1), __l);
    }
or maybe opencode it in there:
  template<__unsigned_integer _Tp>
    [[nodiscard]] constexpr _Tp
    bit_repeat(_Tp __x, int __l)
    {
      __glibcxx_assert( __l > 0 );
      constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits;
      if (__l >= _Nd)
        return __x;
      if (__builtin_constant_p(__l) && !__builtin_constant_p(__x))
        {
          __x &= ((_Tp)1 << __l) - 1;
          __v = _Tp(1);
          do
            {
              __v |= __v << __l;
              __l <<= 1;
            }
          while (__l < _Nd);
          return __x * __v;
        }
      __x &= ((_Tp)1 << __l) - 1;
      do
        {
          __x |= __x << __l;
          __l <<= 1;
        }
      while (__l < _Nd);
      return __x;
    }

Reply via email to