[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Endianness macros capitalization
From: |
Pavel Roskin |
Subject: |
Re: Endianness macros capitalization |
Date: |
Fri, 11 Jul 2008 04:53:42 -0400 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.1.4) |
Quoting Christian Franke <address@hidden>:
#define grub_swap_bytes32(x) \
({ \
grub_uint32_t _x = (x), _y; \
asm ( \
"xchgb %b0,%h0\n" \
"roll $0x10,%0\n" \
"xchgb %b0,%h0\n" \
: "=q"(_y) : "0"(_x) \
); \
_y; \
})
Results are much better for the inline implementation with gcc 4.3.1
(Fedora development AKA Rawhide).
I tried the idea I suggested (let gcc use any register and optimize in
the assembler). The result was a true monstrosity, and it failed to
beat your approach, where gcc is forced to use the first four
registers. The size of all modules together increased by 8 bytes.
However, this code beats everything in my tests by a wide margin:
#define grub_swap_lo(x) \
({ \
grub_uint32_t _x = (x), _y; \
asm ( \
"xchgb %b0,%h0\n" \
: "=q"(_y) : "0"(_x) \
); \
_y; \
})
#define grub_swap_hi(x) \
({ \
grub_uint32_t _x = (x), _y; \
asm ( \
"roll $0x10,%0\n" \
: "=r"(_y) : "0"(_x) \
); \
_y; \
})
#define grub_swap_bytes32(x) grub_swap_lo(grub_swap_hi(grub_swap_lo(x)))
It needs some cleanups to avoid warnings and use better names, but I
think it should go in. Telling gcc the little details really helps.
Sum of module sizes ("du -b -S"):
366976 original
364988 "=q", xchgb
365460 "=q", rolw $8,%w0
365420 "=r", rolw $8,%w0
364996 monstrosity ("=r", conditional xchgb/rolw)
364728 "little details"
With my compiler, everything beats the code we have.
--
Regards,
Pavel Roskin
- Re: Endianness macros capitalization, (continued)
- Re: Endianness macros capitalization, Robert Millan, 2008/07/06
- Re: Endianness macros capitalization, Javier MartÃn, 2008/07/06
- Re: Endianness macros capitalization, Christian Franke, 2008/07/07
- Re: Endianness macros capitalization, Christian Franke, 2008/07/08
- Re: Endianness macros capitalization, Pavel Roskin, 2008/07/09
- Re: Endianness macros capitalization, Christian Franke, 2008/07/09
- Re: Endianness macros capitalization, Pavel Roskin, 2008/07/09
- Re: Endianness macros capitalization, Christian Franke, 2008/07/10
- Re: Endianness macros capitalization, Pavel Roskin, 2008/07/10
- Re: Endianness macros capitalization, Jordi Mallach, 2008/07/11
- Re: Endianness macros capitalization,
Pavel Roskin <=
- Re: Endianness macros capitalization, Pavel Roskin, 2008/07/11
- Re: Endianness macros capitalization, Christian Franke, 2008/07/11
- Re: Endianness macros capitalization, Pavel Roskin, 2008/07/11
- Re: Endianness macros capitalization, Christian Franke, 2008/07/20
- Re: Endianness macros capitalization, Pavel Roskin, 2008/07/20