<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] vec_splats cannot be used to initialize variables with static storage duration"
href="https://bugs.llvm.org/show_bug.cgi?id=44276">44276</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[PowerPC] vec_splats cannot be used to initialize variables with static storage duration
</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>enhancement
</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>Compiling the following C code:
#include <altivec.h>
static vector int a = vec_splats(1);
int main() { return 0; }
results in:
test2.c:2:23: error: initializer element is not a compile-time constant
static vector int a = vec_splats(1);
This compiles on GCC and when compiled as C++ (although not in a C++ constexpr
context).
The definition of vec_splats from altivec.h is:
static __inline__ vector int __ATTRS_o_ai vec_splats(int __a) {
return (vector int)(__a);
}
By manually inlining it, the program compiles:
#include <altivec.h>
static vector int a = (vector int)(1);
int main() { return 0; }
vec_promote is similar in that it GCC allows it to be used to initialize a
variable with static storage duration; however, the present implementation in
LLVM does not allow static initialization even when manually inlined.
I guess the issue here is use of functions rather than macros, but using macros
would run into the same issue as <a class="bz_bug_link
bz_status_NEW "
title="NEW - [PowerPC] Compile error when including x86 vector intrinsics compatibility headers in C++"
href="show_bug.cgi?id=44241">bug #44241</a>; is there some better way to do
this?</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>