[llvm-bugs] [Bug 31551] New: Lower shuffles with equivalent truncates as good as
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 5 07:41:32 PST 2017
https://llvm.org/bugs/show_bug.cgi?id=31551
Bug ID: 31551
Summary: Lower shuffles with equivalent truncates as good as
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: zvi.rackover at intel.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Spinning off from bug 31443:
We should ensure that each 'shufflevector' that has an equivalent 'trunc' form
will be lowered optimally as the trunc.
A random example of two equivalent functions:
define void @shuffle_v16i16_to_v4i16(<16 x i16>* %L, <4 x i16>* %S) nounwind {
%vec = load <16 x i16>, <16 x i16>* %L
%strided.vec = shufflevector <16 x i16> %vec, <16 x i16> undef, <4 x i32>
<i32 0, i32 4, i32 8, i32 12>
store <4 x i16> %strided.vec, <4 x i16>* %S
ret void
}
define void @trunc_v4i64_to_v4i16(<16 x i16>* %L, <4 x i16>* %S) nounwind {
%vec = load <16 x i16>, <16 x i16>* %L
%bc = bitcast <16 x i16> %vec to <4 x i64>
%strided.vec = trunc <4 x i64> %bc to <4 x i16>
store <4 x i16> %strided.vec, <4 x i16>* %S
ret void
}
shuffle_v16i16_to_v4i16 is lowered to:
vmovdqa (%rdi), %ymm0
vextracti128 $1, %ymm0, %xmm1
vpshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
vpshuflw {{.*#+}} xmm1 = xmm1[0,2,2,3,4,5,6,7]
vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
vpshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7]
vpunpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
vmovq %xmm0, (%rsi)
trunc_v4i64_to_v4i16 is lowered to (and can also be improved):
vmovdqa (%rdi), %ymm0
vpmovqd %zmm0, %ymm0
vpshufb {{.*#+}} xmm0 = xmm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
vmovq %xmm0, (%rsi)
--
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/20170105/e9bff5c9/attachment.html>
More information about the llvm-bugs
mailing list