|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4238" status="New"> |
| 5 | +<title><tt>simd_mask<complex<double>>::operator+/-/~</tt> return a disabled `simd` specialization</title> |
| 6 | +<section> |
| 7 | +<sref ref="[simd.mask.unary]"/> |
| 8 | +</section> |
| 9 | +<submitter>Matthias Kretz</submitter> |
| 10 | +<date>27 Mar 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +Consider: |
| 16 | +</p> |
| 17 | +<blockquote><pre> |
| 18 | +simd<complex<double>> c = {}; |
| 19 | +simd_mask<complex<double>> k = (c == c); // sizeof(complex<double>) == 16 |
| 20 | +auto i = -k; // simd<__int128> ! |
| 21 | +</pre></blockquote> |
| 22 | +<p> |
| 23 | +`basic_simd_mask` unary `+`, `-`, and `~` return <tt>basic_simd<<i>integer-from</i><Bytes, Abi>></tt>. |
| 24 | +<sref ref="[simd.expos.defn]"/>/2 says: |
| 25 | +</p> |
| 26 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 27 | +<p> |
| 28 | +<tt><i>integer-from</i><Bytes></tt> is an alias for a signed integer type `T` such that `sizeof(T)` equals `Bytes`. |
| 29 | +</p> |
| 30 | +</blockquote> |
| 31 | +<p> |
| 32 | +But `__int128` isn't a vectorizable type. Consequently, <tt>simd<__int128></tt> currently |
| 33 | +is a disabled specialization. So it seems <tt>simd<complex<double>></tt> wants `__int128` |
| 34 | +to be added to the list of vectorizable types. |
| 35 | +<p/> |
| 36 | +<b>Options:</b> |
| 37 | +</p> |
| 38 | +<ol style="list-style-type:lower-alpha"> |
| 39 | +<li><p>"Specialize" <tt>basic_simd_mask<16, Abi></tt> to return |
| 40 | +<tt>rebind_t<<i>integer-from</i><8>, basic_simd_mask<<i>integer-from</i><16>, Abi>></tt> |
| 41 | +(reduces a 128-bit value of a vector-mask to a 64-bit value in the simd)</p></li> |
| 42 | +<li><p>"Specialize" <tt>basic_simd_mask<16, Abi></tt> to return |
| 43 | +<tt>resize_t<size() * 2, rebind_t<<i>integer-from</i><8>, |
| 44 | +basic_simd_mask<<i>integer-from</i><16>, Abi>>></tt> |
| 45 | +(duplicates a 128-bit value of a vector-mask to two 64-bit values in the simd)</p></li> |
| 46 | +<li><p>delete unary `+`, `-`, and `~` for <tt>basic_simd_mask<16, Abi></tt> |
| 47 | +(closest to the status quo)</p></li> |
| 48 | +</ol> |
| 49 | +</discussion> |
| 50 | + |
| 51 | +<resolution> |
| 52 | +<p> |
| 53 | +This wording is relative to <paper num="N5008"/>. |
| 54 | +</p> |
| 55 | + |
| 56 | +<ol> |
| 57 | + |
| 58 | +<li><p>Modify <sref ref="[simd.mask.unary]"/> as indicated:</p> |
| 59 | + |
| 60 | +<blockquote> |
| 61 | +<pre> |
| 62 | +constexpr basic_simd_mask operator!() const noexcept; |
| 63 | +constexpr basic_simd<<i>integer-from</i><Bytes>, Abi> operator+() const noexcept; |
| 64 | +constexpr basic_simd<<i>integer-from</i><Bytes>, Abi> operator-() const noexcept; |
| 65 | +constexpr basic_simd<<i>integer-from</i><Bytes>, Abi> operator~() const noexcept; |
| 66 | +</pre> |
| 67 | +<blockquote> |
| 68 | +<p> |
| 69 | +-1- Let <tt><i>op</i></tt> be the operator. |
| 70 | +<p/> |
| 71 | +-2- <i>Returns</i>: A data-parallel object where the <tt><i>i</i></tt><sup>th</sup> element |
| 72 | +is initialized to the results of applying <tt><i>op</i></tt> to <tt>operator[](<i>i</i>)</tt> |
| 73 | +for all <tt><i>i</i></tt> in the range of <tt>[0, size())</tt>. |
| 74 | +<p/> |
| 75 | +<ins>-?- <i>Remarks</i>: If <tt>Bytes</tt> is greater than <tt>8</tt>, `operator+()`, `operator-()`, and |
| 76 | +`operator~()` are deleted. |
| 77 | +</ins> |
| 78 | +</p> |
| 79 | +</blockquote> |
| 80 | +</blockquote> |
| 81 | + |
| 82 | +</li> |
| 83 | + |
| 84 | +</ol> |
| 85 | +</resolution> |
| 86 | + |
| 87 | +</issue> |
0 commit comments