<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110834>110834</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][LoongArch] LSX/LASX headers do not work with `-fno-lax-vector-conversions`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xen0n
</td>
</tr>
</table>
<pre>
The current Clang LSX/LASX intrinsics header files make heavy use of implicit vector conversions, that is not accepted by Clang 18+ (Clang 17 does not support Loongson SIMD) with `-fno-lax-vector-conversions`. Example:
```c
// clang -c -fno-lax-vector-conversions -mlsx test-lsx-lax-conversion.c
#include <lsxintrin.h>
int main(void) { return 0; }
```
```
In file included from test-lsx-lax-conversion.c:1:
/usr/lib/llvm/19/bin/../../../../lib/clang/19/include/lsxintrin.h:42:40: error: cannot initialize a parameter of type '__attribute__((__vector_size__(16 * sizeof(char)))) char' (vector of 16 'char' values) with an rvalue of type 'v16i8' (vector of 16 'signed char' values)
42 | return (__m128i)__builtin_lsx_vsll_b((v16i8)_1, (v16i8)_2);
| ^~~~~~~~~
[lots of similar errors omitted]
```
It complicates distribution packaging for certain software, because
1. they require Clang, and
2. effectively one is forced to enable `-flax-vector-conversions` here and there, for example [Skia] and [WebKit] (see the non-applied patch: quick-and-dirty, overly broad and not applicable for mainline, but you get the idea).
So it may be best to just fix the headers to work with strict vector conversion checks, to stop the proliferation of lax coding practice.
[Skia]: https://github.com/google/skia/blob/d063b5e450db822403f05833cc3bf8fc3cdb7350/gn/skia/BUILD.gn#L506
[WebKit]: https://bugs.webkit.org/show_bug.cgi?id=280505
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVUtv4zgS_jX0pWBBoixLPvgQx20g2Owpu5i-CXyUrOrQpJqkHLsP89sHlJzHTHdnDIEwi8Wqrx78SoRAR4u4ZdWOVfuFGGPv_PaCNrcL6f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