<div dir="ltr"><div>Hi,</div><div>wanted to share a quick user perspective.</div><div>Background: I've been using SIMD for a long time and wrote a <a href="https://github.com/google/highway" target="_blank">performance-portable wrapper</a>.</div><div><br></div><div>SVE looks very interesting, but we strongly believe platform-specific implementations are too expensive.</div><div>A cross-platform API is possible, but as Chris mentioned, Add/Div functions are much less ergonomic than infix operators.</div><div><br></div><div>Unfortunately we can't overload operators for SVE types because they are built-in, nor can we</div><div>wrap them in classes because they are sizeless.</div><div><br></div><div>GCC also <a href="https://gcc.godbolt.org/z/xgyAyc">does not define</a> logical operators on float vectors, although they are useful for abs/signbit/copysign.</div><div><br></div><div>Thus we're hoping the compiler can provide built-in operators for all SVE types.</div><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 1, 2020 at 2:39 PM Richard Sandiford via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">"Keane, Erich via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> writes:<br>
>> Before I say anything, I'd like to mention that I am generally in<br>
>> favor of having arithmetic operators defined for vector types.<br>
><br>
> For the rest of 'vector' types, we would almost definitely want to<br>
> implement the operators in clang directly rather than allowing<br>
> overloading. While I appreciate the attractiveness of operator<br>
> overloads on these types, it would be implementation divergence from<br>
> GCC. (ICC Interestingly chose the alternate direction).<br>
<br>
Yeah, this isn't something I would suggest for normal vector types.<br>
With those, anyone who wants to provide their own operators can wrap<br>
the vector in a class.<br>
<br>
SVE types like __SVInt8_t are different because, at the semantic level,<br>
they aren't vector types in the way that clang and GCC understand them.<br>
They're instead just opaque blobs of unspecified size that are manipulated<br>
via intrinsic functions. Their vectorness only becomes apparent during<br>
code generation.<br>
<br>
So clang and GCC are consistent in not providing built-in operators<br>
for __SVInt8_t & co. (I'm not sure you were suggesting otherwise,<br>
I just wanted to clarify.)<br>
<br>
GCC has an -msve-vector-bits=N option that lets you specify the<br>
number of bits in an SVE register. When this is used, types like<br>
__SVInt8_t remain opaque types of unspecified size, to ensure that<br>
the types have the same semantic identity regardless of whether the<br>
vector size is known at compile time. But GCC does allow implicit<br>
conversion between these sizeless types and "normal" fixed-length<br>
vectors of an appropriate type and size, such as those created by<br>
__attribute__((vector_size(N/8))). This makes it possible to use<br>
normal fixed-length vectors with SVE intrinsics. We're planning<br>
to support this for clang too.<br>
<br>
The proposal here would only affect opaque not-really-vector types<br>
like __SVInt8_t. Normal N-bit vectors would be unaffected and<br>
would continue to use the built-in operators.<br>
<br>
Similarly, if in future clang and/or GCC supported a truly<br>
cross-platform variable-length vector extension as part of the<br>
core language, it would probably make sense to allow implicit<br>
conversion between those cross-platform types and the corresponding<br>
opaque SVE types. Here too I imagine the cross-platform types would<br>
use built-in operators.<br>
<br>
Thanks,<br>
Richard<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>