This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/14552] compiled trivial vector intrinsic code is inefficient
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Dec 2005 00:52:39 -0000
- Subject: [Bug target/14552] compiled trivial vector intrinsic code is inefficient
- References: <bug-14552-4523@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #21 from pluto at agmk dot net 2005-12-01 00:52 -------
I'm wondering is it possible to implement tranformations
of vector arithmetics into vector builtins?
e.g.
#include <mmintrin.h>
__v8qi foo(const __v8qi x, const __v8qi y) { return x + y; }
__v8qi bar(const __v8qi x, const __v8qi y) { return _mm_add_pi8(x, y); }
I except from compiler the same code for both functions
but it produces insane code for foo() :/
foo (x, y)
{
unsigned int D.2377;
unsigned int D.2376;
unsigned int D.2369;
unsigned int D.2368;
<bb 0>:
D.2368 = BIT_FIELD_REF <x, 32, 0>;
D.2369 = BIT_FIELD_REF <y, 32, 0>;
D.2376 = BIT_FIELD_REF <x, 32, 32>;
D.2377 = BIT_FIELD_REF <y, 32, 32>;
return VIEW_CONVERT_EXPR<__v8qi>(
{(D.2368 ^ D.2369) & 080808080 ^ (D.2369 & 2139062143) +
(D.2368 & 2139062143),
(D.2376 ^ D.2377) & 080808080 ^ (D.2377 & 2139062143) +
(D.2376 & 2139062143)});
}
bar (x, y)
{
vector signed char D.2448;
<bb 0>:
D.2448 = __builtin_ia32_paddb (
VIEW_CONVERT_EXPR<vector signed char>(VIEW_CONVERT_EXPR<__m64>(x)),
VIEW_CONVERT_EXPR<vector signed char>(VIEW_CONVERT_EXPR<__m64>(y)));
return VIEW_CONVERT_EXPR<__v8qi>(VIEW_CONVERT_EXPR<vector int>(D.2448));
}
# gcc -O2 -march=pentium3 -fomit-frame-pointer -mregparm=3
foo:
subl $44, %esp
movq %mm0, 24(%esp)
movl %ebx, 32(%esp)
movl 24(%esp), %ebx
movl %esi, 36(%esp)
movl 28(%esp), %esi
movq %mm1, 24(%esp)
movl 24(%esp), %eax
movl 28(%esp), %edx
movl %edi, 40(%esp)
movl %ebx, %edi
andl $2139062143, %edi
movl %eax, %ecx
xorl %eax, %ebx
andl $2139062143, %ecx
movl %esi, %eax
addl %edi, %ecx
xorl %edx, %eax
movl 40(%esp), %edi
andl $2139062143, %esi
andl $-2139062144, %ebx
andl $2139062143, %edx
xorl %ecx, %ebx
addl %esi, %edx
andl $-2139062144, %eax
movl 36(%esp), %esi
movl %ebx, 20(%esp)
xorl %edx, %eax
movl 32(%esp), %ebx
movss 20(%esp), %xmm0
movl %eax, 20(%esp)
movss 20(%esp), %xmm1
unpcklps %xmm1, %xmm0
movlps %xmm0, 8(%esp)
movl 8(%esp), %eax
movl 12(%esp), %edx
movl %eax, (%esp)
movl %edx, 4(%esp)
movq (%esp), %mm1
addl $44, %esp
movq %mm1, %mm0
ret
bar:
paddb %mm1, %mm0
ret
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14552