From d874f01054438cd74a59fed3ce10b5da69ff394f Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Sat, 21 Jun 2025 21:22:11 +0200 Subject: [PATCH 1/3] P2876R3 Proposal to extend std::simd with more constructors and accessors --- source/numerics.tex | 68 +++++++++++++++++++++++++++++++++++++++++++++ source/support.tex | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/source/numerics.tex b/source/numerics.tex index 529ed10969..f5cc3c8ee2 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -19095,6 +19095,8 @@ template constexpr explicit basic_simd_mask(const basic_simd_mask&) noexcept; template constexpr explicit basic_simd_mask(G&& gen) noexcept; + constexpr basic_simd_mask(const bitset& b) noexcept; + constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept; // \ref{simd.mask.subscr}, \tcode{basic_simd_mask} subscript operators constexpr value_type operator[](@\exposid{simd-size-type}@) const; @@ -19109,6 +19111,10 @@ template constexpr explicit(sizeof(U) != Bytes) operator basic_simd() const noexcept; + // \ref{simd.mask.namedconv}, \tcode{basic_simd_mask} named type convertors + constexpr bitset to_bitset() const noexcept; + constexpr unsigned long long to_ullong() const; + // \ref{simd.mask.binary}, \tcode{basic_simd_mask} binary operators friend constexpr basic_simd_mask operator&&(const basic_simd_mask&, const basic_simd_mask&) noexcept; @@ -19241,6 +19247,31 @@ \tcode{gen} is invoked exactly once for each $i$, in increasing order of $i$. \end{itemdescr} +\begin{itemdecl} +constexpr basic_simd_mask(const bitset& b) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Initializes the $i^\text{th}$ element with \tcode{b[$i$]} for all $i$ in the +range \range{0}{size()}. +\end{itemdescr} + +\begin{itemdecl} +constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Initializes the first $M$ elements to the corresponding bit values in +\tcode{val}, where $M$ is the smaller of \tcode{size()} and the number of bits in +the value representation \iref{basic.types.general} of the type of \tcode{val}. If +$M$ is less than \tcode{size()}, the remaining elements are initialized to +zero. +\end{itemdescr} + \rSec3[simd.mask.subscr]{\tcode{basic_simd_mask} subscript operator} \begin{itemdecl} @@ -19299,6 +19330,43 @@ \tcode{static_cast(operator[]($i$))}. \end{itemdescr} +\rSec3[simd.mask.namedconv]{\tcode{basic_simd_mask} named conversion operators} + +\begin{itemdecl} +constexpr bitset to_bitset() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{bitset} object where the $i^\text{th}$ element is initialized to +\tcode{operator[]($i$)} for all $i$ in the range \range{0}{size()}. +\end{itemdescr} + +\begin{itemdecl} +constexpr unsigned long long to_ullong() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let $N$ be the width of \tcode{unsigned long long}. + +\pnum +\expects +\begin{itemize} +\item \tcode{size() <= $N$} is \tcode{true}, or +\item for all $i$ in the range \range{$N$}{size()}, \tcode{operator[]($i$)} returns \tcode{false}. +\end{itemize} + +\pnum +\returns +The integral value corresponding to the bits in \tcode{*this}. + +\pnum +\throws +Nothing. +\end{itemdescr} + \rSec2[simd.mask.nonmembers]{Non-member operations} \rSec3[simd.mask.binary]{\tcode{basic_simd_mask} binary operators} diff --git a/source/support.tex b/source/support.tex index 95d674aafb..1486b6f39e 100644 --- a/source/support.tex +++ b/source/support.tex @@ -805,7 +805,7 @@ #define @\defnlibxname{cpp_lib_shared_ptr_weak_type}@ 201606L // also in \libheader{memory} #define @\defnlibxname{cpp_lib_shared_timed_mutex}@ 201402L // also in \libheader{shared_mutex} #define @\defnlibxname{cpp_lib_shift}@ 202202L // also in \libheader{algorithm} -#define @\defnlibxname{cpp_lib_simd}@ 202502L // also in \libheader{simd} +#define @\defnlibxname{cpp_lib_simd}@ 202506L // also in \libheader{simd} #define @\defnlibxname{cpp_lib_simd_complex}@ 202502L // also in \libheader{simd} #define @\defnlibxname{cpp_lib_smart_ptr_for_overwrite}@ 202002L // also in \libheader{memory} #define @\defnlibxname{cpp_lib_smart_ptr_owner_equality}@ 202306L // also in \libheader{memory} From 6fdb0fcbc9d32c19d1c079a83c6f39229a836751 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Sat, 21 Jun 2025 21:25:38 +0200 Subject: [PATCH 2/3] [simd.mask.namedconv] Use math expression for precondition --- source/numerics.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/numerics.tex b/source/numerics.tex index f5cc3c8ee2..1065f6725b 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -19354,7 +19354,7 @@ \pnum \expects \begin{itemize} -\item \tcode{size() <= $N$} is \tcode{true}, or +\item \tcode{size()} $\le N$, or \item for all $i$ in the range \range{$N$}{size()}, \tcode{operator[]($i$)} returns \tcode{false}. \end{itemize} From 9aa27373ec8572d0741e8b85ae913a4774aa6173 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Mon, 23 Jun 2025 17:05:22 +0200 Subject: [PATCH 3/3] [simd.mask.ctor] Remove space before \iref --- source/numerics.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/numerics.tex b/source/numerics.tex index 1065f6725b..210d21a2d9 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -19267,7 +19267,7 @@ \effects Initializes the first $M$ elements to the corresponding bit values in \tcode{val}, where $M$ is the smaller of \tcode{size()} and the number of bits in -the value representation \iref{basic.types.general} of the type of \tcode{val}. If +the value representation\iref{basic.types.general} of the type of \tcode{val}. If $M$ is less than \tcode{size()}, the remaining elements are initialized to zero. \end{itemdescr}