This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/32605] massive moves instead of bswap{l,q}
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jul 2007 15:22:12 -0000
- Subject: [Bug target/32605] massive moves instead of bswap{l,q}
- References: <bug-32605-7667@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from pluto at agmk dot net 2007-07-05 15:22 -------
it would be nice to see bswap variants instead of mov,mov,mov,...
<reverse(unsigned int&)>:
mov (%rdi),%eax
bswap %eax
mov %eax,(%rdi)
retq
<reverse(unsigned long&)>:
mov (%rdi),%rax
bswap %rax
mov %rax,(%rdi)
retq
and one more thing. the 4.2 produces better code than 4.3:
4.2:
void reverse(T&) [with T = size_t] (t)
{
unsigned char & __b.235;
unsigned char & __b.234;
unsigned char & __b.233;
unsigned char __tmp.232;
unsigned char __tmp.231;
unsigned char __tmp.230;
unsigned char * bytes.226;
unsigned char * bytes.225;
unsigned char * bytes.224;
unsigned char & __b;
unsigned char __tmp;
unsigned char * bytes;
<bb 2>:
bytes = (unsigned char *) t;
__b.233 = bytes + 8B - 1B;
__tmp.230 = *bytes;
*bytes = *__b.233;
*__b.233 = __tmp.230;
bytes.224 = bytes + 1B;
__b = __b.233 - 1B;
__tmp = *bytes.224;
*bytes.224 = *__b;
*__b = __tmp;
bytes.225 = bytes.224 + 1B;
__b.235 = __b - 1B;
__tmp.232 = *bytes.225;
*bytes.225 = *__b.235;
*__b.235 = __tmp.232;
bytes.226 = bytes.225 + 1B;
__b.234 = __b.235 - 1B;
__tmp.231 = *bytes.226;
*bytes.226 = *__b.234;
*__b.234 = __tmp.231;
return;
}
4.3:
_ForwardIterator2 std::swap_ranges(_ForwardIterator1,
_ForwardIterator1, _ForwardIterator2)
[with _ForwardIterator1 = unsigned char*,
_ForwardIterator2 = std::reverse_iterator<unsigned char*>]
(__first1, __last1, __first2)
{
long unsigned int D.25754;
struct reverse_iterator D.25507;
<bb 2>:
if (__first1 != __last1)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
D.25507.current = __first2->current;
iter_swap (__first1, &D.25507);
D.25754 = (long unsigned int) __first1 + 1;
__first1 = (unsigned char *) D.25754;
__first2->current = __first2->current + 0xffffffffffffffffffffffffffffffff;
if (__first1 != __last1)
goto <bb 3>;
else
goto <bb 4>;
<bb 4>:
<retval>->current = __first2->current;
return <retval>;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32605