Hi gcc-patches mailing list,
Matthias Kretz via Sourceware Forge 
<[email protected]> has requested that the following 
forgejo pull request
be published on the mailing list.

Created on: 2026-03-21 13:52:32+00:00
Latest update: 2026-05-22 08:07:53+00:00
Changes: 25 changed files, 3487 additions, 120 deletions
Head revision: mkretz/gcc ref std-simd-complex commit 
db5398e40d7dcde44f07382b1d954f327229b1a8
Base revision: gcc/gcc-TEST ref trunk commit 
2ba702c966e3772d3d4e29e4b25beb7ef4dabf73 r17-638-g2ba702c966e377
Merge base: 2ba702c966e3772d3d4e29e4b25beb7ef4dabf73
Full diff url: https://forge.sourceware.org/gcc/gcc-TEST/pulls/145.diff
Discussion:  https://forge.sourceware.org/gcc/gcc-TEST/pulls/145
Requested Reviewers:

This patch set
- refactors std::simd's ABI tags to completely drop `_ScalarAbi<N>`
- adds complex to the vectorizable types
- implements [simd.bit]

Tested on x86_64-linux-gnu, also with unix/-m32/-march=i686


Changed files:
- A: libstdc++-v3/include/bits/simd_bit.h
- A: libstdc++-v3/include/bits/simd_complex.h
- A: libstdc++-v3/include/bits/simd_math.h
- A: libstdc++-v3/testsuite/std/simd/complex_init.h
- A: libstdc++-v3/testsuite/std/simd/simd_bit.cc
- A: libstdc++-v3/testsuite/std/simd/simd_bit_expensive.cc
- M: libstdc++-v3/include/Makefile.am
- M: libstdc++-v3/include/Makefile.in
- M: libstdc++-v3/include/bits/simd_details.h
- M: libstdc++-v3/include/bits/simd_loadstore.h
- M: libstdc++-v3/include/bits/simd_mask.h
- M: libstdc++-v3/include/bits/simd_mask_reductions.h
- M: libstdc++-v3/include/bits/simd_vec.h
- M: libstdc++-v3/include/bits/simd_x86.h
- M: libstdc++-v3/include/bits/vec_ops.h
- M: libstdc++-v3/include/bits/version.def
- M: libstdc++-v3/include/bits/version.h
- M: libstdc++-v3/include/std/simd
- M: libstdc++-v3/testsuite/std/simd/arithmetic.cc
- M: libstdc++-v3/testsuite/std/simd/create_tests.h
- M: libstdc++-v3/testsuite/std/simd/mask2.cc
- M: libstdc++-v3/testsuite/std/simd/stores.cc
- M: libstdc++-v3/testsuite/std/simd/test_setup.h
- M: libstdc++-v3/testsuite/std/simd/traits_common.cc
- M: libstdc++-v3/testsuite/std/simd/traits_impl.cc


Matthias Kretz (2):
  libstdc++: Refactor _ScalarAbi<N> into _Abi<N, N>
  libstdc++: Add std::complex to the [simd] vectorizable types

 libstdc++-v3/include/Makefile.am              |    3 +
 libstdc++-v3/include/Makefile.in              |    3 +
 libstdc++-v3/include/bits/simd_bit.h          |  177 ++
 libstdc++-v3/include/bits/simd_complex.h      | 2321 +++++++++++++++++
 libstdc++-v3/include/bits/simd_details.h      |  218 +-
 libstdc++-v3/include/bits/simd_loadstore.h    |    4 +
 libstdc++-v3/include/bits/simd_mask.h         |  200 +-
 .../include/bits/simd_mask_reductions.h       |    2 +-
 libstdc++-v3/include/bits/simd_math.h         |  125 +
 libstdc++-v3/include/bits/simd_vec.h          |   25 +-
 libstdc++-v3/include/bits/simd_x86.h          |   46 +
 libstdc++-v3/include/bits/vec_ops.h           |   64 +-
 libstdc++-v3/include/bits/version.def         |   11 +
 libstdc++-v3/include/bits/version.h           |    9 +
 libstdc++-v3/include/std/simd                 |    6 +
 libstdc++-v3/testsuite/std/simd/arithmetic.cc |    3 +-
 .../testsuite/std/simd/complex_init.h         |   17 +
 .../testsuite/std/simd/create_tests.h         |    6 +-
 libstdc++-v3/testsuite/std/simd/mask2.cc      |    3 +-
 libstdc++-v3/testsuite/std/simd/simd_bit.cc   |  123 +
 .../testsuite/std/simd/simd_bit_expensive.cc  |    7 +
 libstdc++-v3/testsuite/std/simd/stores.cc     |    4 +-
 libstdc++-v3/testsuite/std/simd/test_setup.h  |   42 +-
 .../testsuite/std/simd/traits_common.cc       |  129 +
 .../testsuite/std/simd/traits_impl.cc         |   59 +-
 25 files changed, 3487 insertions(+), 120 deletions(-)
 create mode 100644 libstdc++-v3/include/bits/simd_bit.h
 create mode 100644 libstdc++-v3/include/bits/simd_complex.h
 create mode 100644 libstdc++-v3/include/bits/simd_math.h
 create mode 100644 libstdc++-v3/testsuite/std/simd/complex_init.h
 create mode 100644 libstdc++-v3/testsuite/std/simd/simd_bit.cc
 create mode 100644 libstdc++-v3/testsuite/std/simd/simd_bit_expensive.cc

Range-diff against v1:
1:  10b41209bf7b = 1:  b5bab8901212 libstdc++: Refactor _ScalarAbi<N> into 
_Abi<N, N>
2:  f5be2c93bb69 ! 2:  db5398e40d7d libstdc++: Add std::complex to the [simd] 
vectorizable types
    @@ Commit message
         _M_abs() is not and cannot be implemented without [simd.math] (sqrt and
         hypot).
     
    -    Signed-off-by: Matthias Kretz <[email protected]>
    -
         libstdc++-v3/ChangeLog:
                 * include/Makefile.am: Add bits/simd_bit.h, 
bits/simd_complex.h,
                 and bit/simd_math.
    @@ Commit message
                 Test __complex_like. Add a test that _CxIleav is dropped when
                 rebinding to the member of a _CxIleav mask.
     
    -    libstdc++: Make default simd tests cheaper; add expensive tests
    -
    -    Use GCC_TEST_RUN_EXPENSIVE=something to compile the more expensive
    -    tests (constexpr and const-prop testing) and to enable more / different
    -    widths for the test type.
    -
         Signed-off-by: Matthias Kretz <[email protected]>
     
    -    libstdc++-v3/ChangeLog:
    -
    -            * testsuite/std/simd/simd_bit.cc: Remove dg-timeout-factor.
    -            * testsuite/std/simd/simd_bit_expensive.cc: Expensive variant 
of
    -
      ## libstdc++-v3/include/Makefile.am ##
     @@ libstdc++-v3/include/Makefile.am: bits_headers = \
        ${bits_srcdir}/shared_ptr_atomic.h \
    @@ libstdc++-v3/include/bits/simd_complex.h (new)
     +      // TODO: conversion extensions
     +
     +      // [simd.ctor] broadcast constructor 
------------------------------------
    -+      template <__explicitly_convertible_to<value_type> _Up>
    ++      template <__broadcast_constructible<value_type> _Up>
     +  [[__gnu__::__always_inline__]]
    -+  constexpr explicit(!__broadcast_constructible<_Up, value_type>)
    ++  constexpr
     +  basic_vec(_Up&& __x) noexcept
     +    : _M_data([&](int __i) {
     +        if constexpr (__complex_like<_Up>)
    @@ libstdc++-v3/include/bits/simd_complex.h (new)
     +      })
     +  {}
     +
    -+      template <__simd_vec_bcast_consteval<value_type> _Up>
    -+  consteval
    -+  basic_vec(const _Up& __x)
    -+  : basic_vec(__value_preserving_cast<value_type>(__x))
    -+  {}
    -+
     +      // [simd.ctor] conversion constructor 
-----------------------------------
     +      template <__complex_like _Up, typename _UAbi>
     +  requires (_S_size == _UAbi::_S_size)
    @@ libstdc++-v3/include/bits/simd_complex.h (new)
     +      // TODO: conversion extensions
     +
     +      // [simd.ctor] broadcast constructor 
------------------------------------
    -+      template <__explicitly_convertible_to<value_type> _Up>
    ++      template <__broadcast_constructible<value_type> _Up>
     +  requires __complex_like<_Up>
     +  [[__gnu__::__always_inline__]]
    -+  constexpr explicit(!__broadcast_constructible<_Up, value_type>)
    ++  constexpr
     +  basic_vec(_Up&& __x) noexcept
     +    : _M_real(__x.real()), _M_imag(__x.imag())
     +  {}
     +
    -+      template <__explicitly_convertible_to<value_type> _Up>
    ++      template <__broadcast_constructible<value_type> _Up>
     +  [[__gnu__::__always_inline__]]
    -+  constexpr explicit(!__broadcast_constructible<_Up, value_type>)
    ++  constexpr
     +  basic_vec(_Up&& __x) noexcept
     +    : _M_real(__x), _M_imag()
     +  {}
     +
    -+      template <__simd_vec_bcast_consteval<value_type> _Up>
    -+  consteval
    -+  basic_vec(const _Up& __x)
    -+  : _M_real(__x), _M_imag()
    -+  {}
    -+
     +      // [simd.ctor] conversion constructor 
-----------------------------------
     +      template <__complex_like _Up, typename _UAbi>
     +  requires (_S_size == _UAbi::_S_size)
    @@ libstdc++-v3/include/bits/version.def: ftms = {
     +  };
     +};
     +
    - // Standard test specifications.
    - stds[97] = ">= 199711L";
    - stds[03] = ">= 199711L";
    + ftms = {
    +   name = is_structural;
    +   values = {
     
      ## libstdc++-v3/include/bits/version.h ##
     @@
    @@ libstdc++-v3/include/bits/version.h
     +#endif /* !defined(__cpp_lib_simd_complex) */
     +#undef __glibcxx_want_simd_complex
     +
    - #undef __glibcxx_want_all
    + #if !defined(__cpp_lib_is_structural)
    + # if (__cplusplus >  202302L) && (__has_builtin(__builtin_is_structural))
    + #  define __glibcxx_is_structural 202603L
     
      ## libstdc++-v3/include/std/simd ##
     @@
    @@ libstdc++-v3/include/std/simd
     
      ## libstdc++-v3/testsuite/std/simd/arithmetic.cc ##
     @@
    - // { dg-require-effective-target x86 }
    + // { dg-additional-options "-msse2" }
      
      #include "test_setup.h"
     +#include "complex_init.h"
    @@ libstdc++-v3/testsuite/std/simd/simd_bit.cc (new)
     @@
     +// { dg-do run { target c++26 } }
     +// { dg-require-effective-target x86 }
    ++// { dg-additional-options "-msse2" }
     +
     +#include "test_setup.h"
     +#include <climits>
    @@ libstdc++-v3/testsuite/std/simd/traits_common.cc: template class 
simd::basic_vec
     +    simd::vec<float, 4> vh2f_b = float16_t();
     +
     +    simd::vec<float16_t, 4> vf2h = {f4, simd::flag_convert};
    -+    simd::vec<float16_t, 4> vf2h_b{float()};
     +
     +    vh2f = vf2h;
     +    vf2h = static_cast<decltype(vf2h)>(vh2f);
     +
    -+    return all_of(vh2f == vh2f_b) && all_of(vf2h == vf2h_b);
    ++    return all_of(vh2f == vh2f_b);
     +  }());
     +}
     +#endif
    @@ libstdc++-v3/testsuite/std/simd/traits_common.cc: namespace test02
        // ensure 'true ? int : vec<float>' doesn't work
        template <typename T>
          concept has_type_member = requires { typename T::type; };
    -   static_assert(has_type_member<common_type<int, simd::vec<float>>>);
    +   static_assert(!has_type_member<common_type<int, simd::vec<float>>>);
     +
     +  constexpr simd::vec<complex<double>>::mask_type k = {};
      }
    @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc
      namespace simd = std::simd;
      
     +using std::complex;
    + #ifdef __STDCPP_FLOAT16_T__
      using std::float16_t;
    - using std::float32_t;
    - using std::float64_t;
    + #endif
     @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc: void test()
          {
            using T = decltype(t);
    @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc: void test()
            static_assert(sizeof(__integer_from<N>) == N);
            static_assert(__vectorizable<__integer_from<N>>);
          }
    -+  template for (constexpr int N : {2, 4, 8})
    ++  template for (constexpr int N : {
    ++#ifdef __STDCPP_BFLOAT16_T__
    ++                            2,
    ++#endif
    ++                            4, 8})
     +    {
     +      static_assert(std::floating_point<__float_from<N>>);
     +      static_assert(sizeof(__float_from<N>) == N);
    @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc: void test()
     +      static_assert(!AC2::_S_is_cx_ctgus);
          }
      
    ++#if __glibcxx_simd_complex
     +  {
     +    using ACx2 = _Abi_t<2, 2, _AbiVariant::_CxIleav>;
     +    static_assert(__abi_tag<ACx2>);
    @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc: void test()
     +    static_assert(AM4::_S_size == ACx2::_S_size * 2);
     +    static_assert(!AM4::_S_is_cx_ileav);
     +  }
    ++#endif
     +
        static_assert(__streq_to_1("1"));
        static_assert(!__streq_to_1(""));
    @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc: void test()
     +  static_assert( __value_preserving_convertible_to<double, 
complex<double>>);
     +  static_assert(!__value_preserving_convertible_to<double, 
complex<float>>);
      
    + #ifdef __STDCPP_FLOAT16_T__
        static_assert(__explicitly_convertible_to<float, float16_t>);
    -   static_assert(__explicitly_convertible_to<long, float16_t>);
     @@ libstdc++-v3/testsuite/std/simd/traits_impl.cc: void test()
    -   static_assert(__broadcast_constructible<decltype(std::cw<2>), float>);
        static_assert(__broadcast_constructible<decltype(std::cw<0.f>), 
std::float16_t>);
    + #endif
      
     +  static_assert( __broadcast_constructible<complex<float>, 
complex<float>>);
     +  static_assert( __broadcast_constructible<complex<float>, 
complex<double>>);
-- 
2.54.0

Reply via email to