diff options
author | marxin <mliska@suse.cz> | 2019-03-05 22:27:02 +0100 |
---|---|---|
committer | marxin <mliska@suse.cz> | 2019-03-05 22:27:02 +0100 |
commit | 64bce5a24bcf9c2d1ab1548c41a51626228583cc (patch) | |
tree | 735a3aa1041325eea5b34198e0bf6fb0ebc09533 /doc | |
parent | c40877bc6ac81ecf0b8dc70ad1c708ac1b2bf167 (diff) |
Use GCC builtins for bswap as compiler can then emit these via instructions.
Using current macros, one get for:
static inline int BSWAP32(int x) {
return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24));
}
int main(int argc, char **argv)
{
return BSWAP32(argc);
}
main:
.LFB1:
.cfi_startproc
movl %edi, %eax
movl %edi, %edx
sarl $24, %edx
sall $24, %eax
orl %edx, %eax
movl %edi, %edx
sarl $8, %edi
sall $8, %edx
andl $65280, %edi
andl $16711680, %edx
orl %edx, %eax
orl %edi, %eax
ret
while using:
int main(int argc, char **argv)
{
return __builtin_bswap32(argc);
}
one gets:
main:
.LFB0:
.cfi_startproc
movl %edi, %eax
bswap %eax
ret
Diffstat (limited to 'doc')
0 files changed, 0 insertions, 0 deletions