<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - [x86] bad codegen while extracting vector elements"
href="https://llvm.org/bugs/show_bug.cgi?id=25543">25543</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[x86] bad codegen while extracting vector elements
</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>All
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>It may be possible to further reduce this, but here's a small C example that
shows the problem(s):
$ cat shifty.c
#include <immintrin.h>
void foo(__m128i v, int bits, short *s0, short *s1) {
int i[4];
_mm_storeu_si128((__m128i *)i, v); // get vector bits as ints
if (bits & 1) { *s0 = i[0]; } // conditionally store part of elt 0
if (bits & 2) { *s1 = i[1]; } // conditionally store part of elt 1
}
Testing with:
$ ./clang -v
clang version 3.8.0 (trunk 253043)
Target: x86_64-apple-darwin15.0.0
$ ./clang -fomit-frame-pointer -O2 shifty.c -S -o -
_foo:
movd %xmm0, %rax # Wrong disasm? That's a 64-bit move (movq).
testb $1, %dil
je LBB0_2
movw %ax, (%rsi)
LBB0_2:
testb $2, %dil
je LBB0_4
# Things get weird...why are we messing with elements 2 and 3?
pshufd $78, %xmm0, %xmm0 ## xmm0 = xmm0[2,3,0,1]
movd %xmm0, %rcx
shldq $32, %rax, %rcx # Could have just shifted %rax left?
movw %cx, (%rdx)
LBB0_4:
retq</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>