[LLVMbugs] [Bug 17479] New: Vector conversion problem with x86 SSE/AVX
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Oct 4 11:50:10 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17479
Bug ID: 17479
Summary: Vector conversion problem with x86 SSE/AVX
Product: tools
Version: 3.2
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: llc
Assignee: unassignedbugs at nondot.org
Reporter: arsene.perard at laposte.net
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131004/04afa2cb/attachment.html>
More information about the llvm-bugs
mailing list