<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 - [SIMD] __builtin_popcount in loop with 8-bit type should generate i8x16.popcnt"
href="https://bugs.llvm.org/show_bug.cgi?id=50795">50795</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SIMD] __builtin_popcount in loop with 8-bit type should generate i8x16.popcnt
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>clang@evan.coeusgroup.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>This *may* be the same issue as #50247, but I suspect it's a bit more
complicated since `__builtin_popcount` takes a 32-bit integer. Unfortunately
there is no __builtin_popcountb, though :(
If you loop through a vector of bytes and call __builtin_popcount (with
appropriate casts) it would be great if LLVM could just generate an
i8x16.popcnt instead of the mess it currently outputs. Quick example (or on
Compiler Explorer if you prefer: <a href="https://godbolt.org/z/sPMe4na66">https://godbolt.org/z/sPMe4na66</a>)
#include <wasm_simd128.h>
#pragma clang diagnostic ignored "-Wmissing-prototypes"
typedef int8_t i8x16 __attribute__((__vector_size__(16)));
i8x16 popcnt(i8x16 a) {
i8x16 r;
for (int i = 0 ; i < 16 ; i++) {
r[i] = (int8_t) __builtin_popcount((unsigned int) a[i]);
}
// False positive. Happens for the math functions, too... very annoying
#pragma clang diagnostic ignored "-Wconditional-uninitialized"
return r;
}
i8x16 popcnt_intrin(i8x16 a) {
return __builtin_wasm_popcnt_i8x16(a);
}</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>