<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 - -msse4 -O0 segfault"
href="https://bugs.llvm.org/show_bug.cgi?id=34142">34142</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-msse4 -O0 segfault
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hjl.tools@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>[hjl@gnu-tools-1 pr81389]$ cat x.c
#include <nmmintrin.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
__m128i key128 = { ':' };
const char data[] = "___0123456789:_:abcdefghijklmn";
const char* ptr = argc < 100 ? data : argv[1];
int idx = _mm_cmpestri(key128, 1,
*(const __m128i*)(ptr+3), 16, // don't require memory
align
_SIDD_UBYTE_OPS|_SIDD_CMP_EQUAL_ORDERED|_SIDD_LEAST_SIGNIFICANT);
printf("%zd\n", idx);
return 0;
}
[hjl@gnu-tools-1 pr81389]$ clang -msse4 -O0 x.c
[hjl@gnu-tools-1 pr81389]$ ./a.out
Segmentation fault (core dumped)
[hjl@gnu-tools-1 pr81389]$ clang -msse4 -O2 x.c
[hjl@gnu-tools-1 pr81389]$ ./a.out
10
[hjl@gnu-tools-1 pr81389]$
"*(const __m128i*)(ptr+3)" is an incorrect cast. GCC supports __m128i_u
for this:
[hjl@gnu-tools-1 pr81389]$ cat y.c
#include <nmmintrin.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
__m128i key128 = { ':' };
const char data[] = "___0123456789:_:abcdefghijklmn";
const char* ptr = argc < 100 ? data : argv[1];
int idx = _mm_cmpestri(key128, 1,
*(const __m128i_u*)(ptr+3), 16, // don't require memory
align
_SIDD_UBYTE_OPS|_SIDD_CMP_EQUAL_ORDERED|_SIDD_LEAST_SIGNIFICANT);
printf("%zd\n", idx);
return 0;
}
[hjl@gnu-tools-1 pr81389]$ gcc -msse4 -O0 y.c
[hjl@gnu-tools-1 pr81389]$ ./a.out
10
[hjl@gnu-tools-1 pr81389]$ gcc -msse4 -O2 y.c
[hjl@gnu-tools-1 pr81389]$ ./a.out
10
[hjl@gnu-tools-1 pr81389]$ clang -msse4 -O0 y.c
y.c:9:12: error: unknown type name '__m128i_u'; did you mean '__m128i'?
*(const __m128i_u*)(ptr+3), 16, // don't requir...
^~~~~~~~~
__m128i
/usr/bin/../lib64/clang/4.0.0/include/smmintrin.h:426:55: note: expanded from
macro '_mm_cmpestri'
(__v16qi)(__m128i)(B), (int)(LB), \
^
/usr/bin/../lib64/clang/4.0.0/include/emmintrin.h:30:19: note: '__m128i'
declared here
typedef long long __m128i __attribute__((__vector_size__(16)));
^
1 error generated.
[hjl@gnu-tools-1 pr81389]$</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>