[llvm-bugs] [Bug 51746] New: Suboptimal auto vectorized code with accumulator
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Sep 4 02:52:52 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51746
Bug ID: 51746
Summary: Suboptimal auto vectorized code with accumulator
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
typedef int v4si __attribute__ ((vector_size (16)));
int
test1 (int acc, v4si v1, v4si v2, v4si v3, v4si v4)
{
acc &= v1[0] & v1[1] & v1[2] & v1[3];
acc &= v2[0] & v2[1] & v2[2] & v2[3];
acc &= v3[0] & v3[1] & v3[2] & v3[3];
acc &= v4[0] & v4[1] & v4[2] & v4[3];
return acc;
}
GGC -O3:
test1(int, int __vector(4), int __vector(4), int __vector(4), int __vector(4)):
pand xmm0, xmm1
pand xmm2, xmm3
pand xmm2, xmm0
pshufd xmm0, xmm2, 85
movd edx, xmm2
movd eax, xmm0
movdqa xmm0, xmm2
and eax, edx
punpckhdq xmm0, xmm2
pshufd xmm2, xmm2, 255
and eax, edi
movd edx, xmm0
and edx, eax
movd eax, xmm2
and eax, edx
ret
Clang -O3:
test1(int, int __vector(4), int __vector(4), int __vector(4), int __vector(4)):
# @test1(int, int __vector(4), int __vector(4), int
__vector(4), int __vector(4))
movd eax, xmm1
pshufd xmm4, xmm1, 85 # xmm4 = xmm1[1,1,1,1]
movd ecx, xmm4
and ecx, eax
pshufd xmm4, xmm1, 238 # xmm4 = xmm1[2,3,2,3]
movd eax, xmm4
and eax, ecx
pshufd xmm1, xmm1, 255 # xmm1 = xmm1[3,3,3,3]
movd ecx, xmm1
movd edx, xmm2
pshufd xmm1, xmm2, 85 # xmm1 = xmm2[1,1,1,1]
movd esi, xmm1
and esi, ecx
and esi, edx
pshufd xmm1, xmm2, 238 # xmm1 = xmm2[2,3,2,3]
movd ecx, xmm1
and ecx, esi
pshufd xmm1, xmm2, 255 # xmm1 = xmm2[3,3,3,3]
movd edx, xmm1
and edx, ecx
movd ecx, xmm3
pshufd xmm1, xmm3, 85 # xmm1 = xmm3[1,1,1,1]
movd esi, xmm1
and esi, ecx
pshufd xmm1, xmm3, 238 # xmm1 = xmm3[2,3,2,3]
movd ecx, xmm1
and ecx, esi
pshufd xmm1, xmm3, 255 # xmm1 = xmm3[3,3,3,3]
movd esi, xmm1
and esi, ecx
pshufd xmm1, xmm0, 238 # xmm1 = xmm0[2,3,2,3]
pand xmm1, xmm0
pshufd xmm0, xmm1, 85 # xmm0 = xmm1[1,1,1,1]
pand xmm0, xmm1
movd ecx, xmm0
and eax, edi
and eax, ecx
and eax, edx
and eax, esi
ret
Codegen: https://godbolt.org/z/Y86fodv5j
--
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/20210904/2d882c68/attachment-0001.html>
More information about the llvm-bugs
mailing list