<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [PowerPC] Compile error when including x86 vector intrinsics compatibility headers in C++"
href="https://bugs.llvm.org/show_bug.cgi?id=44241">44241</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[PowerPC] Compile error when including x86 vector intrinsics compatibility headers in C++
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Headers
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>colin.samples@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22915" name="attach_22915" title="Patch to fix typedefs">attachment 22915</a> <a href="attachment.cgi?id=22915&action=edit" title="Patch to fix typedefs">[details]</a></span>
Patch to fix typedefs
On ppc64le, this can be reproduced with:
$ echo -e "#include <xmmintrin.h>\nint main() {}" > test1.cpp
$ clang++ test.cpp -DNO_WARN_X86_INTRINSICS
And results in the following error:
/home/colin/devel/llvm-builds/master-clang-assert/lib/clang/10.0.0/include/ppc_wrappers/xmmintrin.h:978:42:
error: controlling expression type '__v4sf' (vector of 4 'float' values) not
compatible with any generic association type
result = (__vector unsigned long long) vec_cts (rounded, 0);
^~~~~~~~~~~~~~~~~~~~
/home/colin/devel/llvm-builds/master-clang-assert/lib/clang/10.0.0/include/altivec.h:2914:12:
note: expanded from macro 'vec_cts'
_Generic((__a), vector float
\
^~~~~
[...]
This also affects Clang 9.
The issue occurs because the `*mmintrin.h` PPC compatibility headers define
typedefs to map the Intel vector types to the AltiVec types. The typedefs use
the `__vector_size__` type attribute instead of the `__vector` keyword.
`altivec.h` uses C11 generics for `vec_ctf`, `vec_cts`, `vec_ctu`,
`vec_shasigma_be`, and `vec_test_data_class`. Per the docs:
In C, type compatibility is decided according to the rules given in
the appropriate standard, but in C++, which lacks the type
compatibility rules used in C, types are considered compatible only
if they are equivalent.
Use of these functions in C++ programs with the `*mmintrin.h` typedef results
in the same compiler error. Note that the `vec_ct*` will not work with
`__vector float` until <a class="bz_bug_link
bz_status_NEW "
title="NEW - Instruction selection fails for %llvm.ppc.altivec.vct* with a non-zero argument"
href="show_bug.cgi?id=44239">bug #44239</a> is resolved.
See attached for a patch that changes the typedefs to use the `__vector`
keyword. Not sure if this is the best approach, since this fixes the issue for
the compatibility headers but not for user specified typedefs using
`__vector_size__`.
Another option I worked up would be to create overload sets for C++, as in the
second attachment.
But let me know if you would like me to work this up further or if there is a
better way.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>