Skip to content

Commit e71585b

Browse files
committed
New issue from Matthias Kretz: "simd_mask<complex<double>>::operator+/-/~ return a disabled simd specialization"
1 parent 1f92429 commit e71585b

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

xml/issue4238.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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&lt;complex&lt;double&gt;&gt;::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&lt;complex&lt;double&gt;&gt; c = {};
19+
simd_mask&lt;complex&lt;double&gt;&gt; k = (c == c); // sizeof(complex&lt;double&gt;) == 16
20+
auto i = -k; // simd&lt;__int128&gt; !
21+
</pre></blockquote>
22+
<p>
23+
`basic_simd_mask` unary `+`, `-`, and `~` return <tt>basic_simd&lt;<i>integer-from</i>&lt;Bytes, Abi&gt;&gt;</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>&lt;Bytes&gt;</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&lt;__int128&gt;</tt> currently
33+
is a disabled specialization. So it seems <tt>simd&lt;complex&lt;double&gt;&gt;</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&lt;16, Abi&gt;</tt> to return
40+
<tt>rebind_t&lt;<i>integer-from</i>&lt;8&gt;, basic_simd_mask&lt;<i>integer-from</i>&lt;16&gt;, Abi&gt;&gt;</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&lt;16, Abi&gt;</tt> to return
43+
<tt>resize_t&lt;size() * 2, rebind_t&lt;<i>integer-from</i>&lt;8&gt;,
44+
basic_simd_mask&lt;<i>integer-from</i>&lt;16&gt;, Abi&gt;&gt;&gt;</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&lt;16, Abi&gt;</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&lt;<i>integer-from</i>&lt;Bytes&gt;, Abi&gt; operator+() const noexcept;
64+
constexpr basic_simd&lt;<i>integer-from</i>&lt;Bytes&gt;, Abi&gt; operator-() const noexcept;
65+
constexpr basic_simd&lt;<i>integer-from</i>&lt;Bytes&gt;, Abi&gt; 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

Comments
 (0)