[LLVMbugs] [Bug 10421] New: incorrect code generated for shufflevector with i8 types (x86)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jul 20 04:01:50 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10421
Summary: incorrect code generated for shufflevector with i8
types (x86)
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: matt at pharr.org
CC: llvmbugs at cs.uiuc.edu
(The following happens with both LLVM 2.9 and top-of-tree.)
Given this bitcode (a reduced test-case), which I would expect to end up
concatenating the two i32 values and returning them as an i64:
define i64 @foo(i32 %a, i32 %b) nounwind readonly {
%va = bitcast i32 %a to <4 x i8>
%vb = bitcast i32 %b to <4 x i8>
%vshuf = shufflevector <4 x i8> %va, <4 x i8> %vb,
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32
7>
%v64 = bitcast <8 x i8> %vshuf to i64
ret i64 %v64
}
And given this test program:
#include <stdio.h>
#include <stdint.h>
extern "C" {
int64_t foo(int32_t, int32_t);
}
int main() {
int32_t a = 0x01010101;
int32_t b = 0x02020202;
int64_t val = foo(a, b);
printf("val = %llx\n", val);
return 0;
}
I get this output:
% llc -o a.s a.ll && g++ a.cpp a.s && ./a.out
val = 1010101
%
(i.e. the 0x02020202 bit is not there in the returned i64 vaue).
The generated assembly is:
_foo: ## @foo
## BB#0:
movd %esi, %xmm0
movd %edi, %xmm1
movlhps %xmm0, %xmm1 ## xmm1 = xmm1[0],xmm0[0]
movd %xmm1, %rax
ret
I'm not an x86 expert, but my reading of that is that the movhlps ends up
incorrectly packing the SSE register like (0, b, 0, a), rather than (0, 0, b,
a), so that the final movd just returns (0, a) as an int64.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list