<html>
<head>
<base href="http://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 --- - Vector conversion problem with x86 SSE/AVX"
href="http://llvm.org/bugs/show_bug.cgi?id=17479">17479</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Vector conversion problem with x86 SSE/AVX
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>3.2
</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>llc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arsene.perard@laposte.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I cannot get llc to generate correct code for a special sequence of
instructions. I actually compare two vectors of floats, get a vector of
booleans, and I want to convert this into an integer bitmask. To do so, I use a
bitcast to convert the boolean vector into a i4 value, and then a zero extend
operation to get an integer. I actually would expect the compiler to output a
movmskps instruction. Here is the code :
@num = private unnamed_addr constant [4 x i8] c"%d\0A\00"
@a = private unnamed_addr constant <4 x float> <float 0.0, float 1.0, float
2.0, float 3.0>
@b = private unnamed_addr constant <4 x float> <float 3.0, float 2.0, float
1.0, float 0.0>
declare i32 @printf(i8* nocapture, i32) nounwind
define i32 @test(<4 x float>* %a, <4 x float>* %b)
{
%1 = load <4 x float>* %a, align 16
%2 = load <4 x float>* %b, align 16
%3 = fcmp ogt <4 x float> %1, %2
%4 = bitcast <4 x i1> %3 to i4
%5 = zext i4 %4 to i32
ret i32 %5
}
define i32 @main() {
%res = call i32 @test(<4 x float>* @a, <4 x float>* @b)
%str = getelementptr [4 x i8]* @num, i64 0, i64 0
call i32 @printf(i8* %str, i32 %res)
ret i32 0
}
And here is the output I get :
test: # @test
.cfi_startproc
# BB#0:
vmovaps (%rsi), %xmm0
vcmpltps (%rdi), %xmm0, %xmm0
vpextrd $2, %xmm0, %ecx
vpextrd $1, %xmm0, %eax
andl $1, %ecx
vpextrd $3, %xmm0, %edx
andl $1, %edx
movb %dl, -4(%rsp)
movb %cl, -4(%rsp)
andl $1, %eax
movb %al, -4(%rsp)
vmovd %xmm0, %eax
andl $1, %eax
movb %al, -4(%rsp)
movzbl -4(%rsp), %eax
ret
Clearly, this code is not correct : it only shows the value of the first
comparison
(Code :
vmovd %xmm0, %eax
andl $1, %eax
),
not the expected bitmask. I'm compiling with "lcc test.ll" and my machine is an
opensuse distribution (12.3) using the lastest packages (llvm 3.2).</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>