[PATCH] libstdc++: Implement P4012R1 while reverting P3844R2 (consteval simd broadcast)

Jonathan Wakely jwakely.gcc@gmail.com
Tue Apr 21 09:57:27 GMT 2026


On Mon, 20 Apr 2026 at 16:52, Matthias Kretz <MatthiasKretz@gmx.net> wrote:
>
> Tested on x86_64-linux-gnu (unix/-march=native and unix/-m32/-march=i686).
>
> OK for trunk?

OK, thanks


>
> -------- 8< ---------
>
> From: Matthias Kretz <m.kretz@gsi.de>
>
> P3844R2 added consteval conversion for value-preserving conversion from
> constants. It had been approved by LEWG in Kona. Therefore, the current
> implementation has the consteval broadcast constructor. In Croydon, LEWG
> reversed the decision but changed the overload set to keep the design
> space open for C++29.
>
> This patch implements the removal of the consteval constructor and
> changes the broadcast constructor according to P4012R1, to keep the
> design space open.
>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/simd_details.h (__value_preserving_cast): Remove.
>         * include/bits/simd_mask.h (basic_mask): Replace plain 0 and 1
>         literals with cw<0> and cw<1>. Replace explicit basic_vec
>         construction from 0 and 1 with default init and broadcast from
>         _Up(1).
>         (_M_to_uint): Replace 1 with cw<1>.
>         * include/bits/simd_vec.h (basic_vec): Remove consteval
>         broadcast overload. Remove explicit broadcast from
>         non-value-preserving types.
>         * testsuite/std/simd/arithmetic.cc: Replace ill-formed integer
>         literals with explicit cast to T or use cw.
>         * testsuite/std/simd/mask.cc: Likewise.
>         * testsuite/std/simd/simd_alg.cc: Likewise.
>         * testsuite/std/simd/traits_common.cc: Adjust for resulting
>         traits changes.
>         * testsuite/std/simd/traits_math.cc: Likewise.
>
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
> ---
>  libstdc++-v3/include/bits/simd_details.h      |  9 --------
>  libstdc++-v3/include/bits/simd_mask.h         | 17 +++++++-------
>  libstdc++-v3/include/bits/simd_vec.h          | 22 ++++---------------
>  libstdc++-v3/testsuite/std/simd/arithmetic.cc | 17 +++++++-------
>  libstdc++-v3/testsuite/std/simd/mask.cc       |  6 ++---
>  libstdc++-v3/testsuite/std/simd/simd_alg.cc   |  5 ++---
>  .../testsuite/std/simd/traits_common.cc       |  4 ++--
>  .../testsuite/std/simd/traits_math.cc         |  2 +-
>  8 files changed, 30 insertions(+), 52 deletions(-)
>
>
> --
> ──────────────────────────────────────────────────────────────────────────
>  Dr. Matthias Kretz                           https://mattkretz.github.io
>  GSI Helmholtz Center for Heavy Ion Research               https://gsi.de
>  std::simd
> ──────────────────────────────────────────────────────────────────────────


More information about the Libstdc++ mailing list