This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/52624] New: Missing __builtin_bswap16
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 19 Mar 2012 17:24:01 +0000
- Subject: [Bug target/52624] New: Missing __builtin_bswap16
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
Bug #: 52624
Summary: Missing __builtin_bswap16
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hjl.tools@gmail.com
CC: ubizjak@gmail.com
Target: x86
__builtin_bswap16 is supported on Powerpc, but is missing on x86.
We can use __builtin_bswap32 (x << 16). But it it is less
efficient:
[hjl@gnu-6 tmp]$ cat b.c
#include <byteswap.h>
short
b1 (short x)
{
return __bswap_16 (x);
}
short
b2 (short x)
{
return __builtin_bswap32 (x << 16);
}
[hjl@gnu-6 tmp]$ gcc -S -O b.c
[hjl@gnu-6 tmp]$ cat b.s
.file "b.c"
.text
.globl b1
.type b1, @function
b1:
.LFB0:
.cfi_startproc
movl %edi, %eax
#APP
# 6 "b.c" 1
rorw $8, %ax
# 0 "" 2
#NO_APP
ret
.cfi_endproc
.LFE0:
.size b1, .-b1
.globl b2
.type b2, @function
b2:
.LFB1:
.cfi_startproc
movl %edi, %eax
sall $16, %eax
bswap %eax
ret
.cfi_endproc
.LFE1:
.size b2, .-b2
.ident "GCC: (GNU) 4.6.3 20120306 (Red Hat 4.6.3-2)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-6 tmp]$