<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 - Clang failed to inline memset for SSE2 and AVX2"
href="https://bugs.llvm.org/show_bug.cgi?id=47200">47200</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang failed to inline memset for SSE2 and AVX2
</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: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zufuliu@163.com
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>following code (online at <a href="https://godbolt.org/z/9eWq78">https://godbolt.org/z/9eWq78</a>), when CNT is larger
than 1 (for both AVX2 and SSE2), clang emits call to memset.
gcc inline the memset call when buffer size is <= 256, e.g. CNT <= 8 for AVX2,
or CNT <= 16 for SSE2.
#include <string.h>
#include <immintrin.h>
#define CNT 2
int IsUTF7(const char *data, size_t length) {
#if defined(__AVX2__)
char buffer[CNT*sizeof(__m256i)] = {0};
memcpy(buffer, data, length);
__m256i chunk = _mm256_loadu_si256((__m256i *)buffer);
return _mm256_movemask_epi8(chunk) == 0;
#else
char buffer[CNT*sizeof(__m128i)] = {0};
memcpy(buffer, data, length);
__m128i chunk = _mm_loadu_si128((__m128i *)buffer);
return _mm_movemask_epi8(chunk) == 0;
#endif
}</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>