[LLVMbugs] [Bug 12762] New: missed bswap.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue May 8 04:18:53 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12762
Bug #: 12762
Summary: missed bswap.
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: pluto at agmk.net
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
here's a tricky example of loop which should emit bswap
for some types.
#include <algorithm>
#include <iterator>
template < typename T >
void __attribute__((noinline)) reverse( T& t )
{
unsigned char* bytes = reinterpret_cast< unsigned char* >( &t );
std::swap_ranges( bytes, bytes + sizeof( T ) / 2,
std::reverse_iterator< unsigned char* >( bytes + sizeof( T ) )
);
}
template void reverse( std::size_t& );
int main()
{
std::size_t x = 0x0011223344556677ull;
reverse( x );
return ( x == 0x7766554433221100ull ? 0 : 1 );
}
currently it's transformed to:
_Z7reverseImEvRT_:
movb (%rdi), %al
movb 7(%rdi), %cl
movb %cl, (%rdi)
movb %al, 7(%rdi)
movb 1(%rdi), %al
movb 6(%rdi), %cl
movb %cl, 1(%rdi)
movb %al, 6(%rdi)
movb 2(%rdi), %al
movb 5(%rdi), %cl
movb %cl, 2(%rdi)
movb %al, 5(%rdi)
movb 3(%rdi), %al
movb 4(%rdi), %cl
movb %cl, 3(%rdi)
movb %al, 4(%rdi)
ret
--
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