mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-22 03:48:57 +00:00
Random note about bswap.
llvm-svn: 108396
This commit is contained in:
parent
01c2381bd7
commit
fc1680a9af
@ -631,3 +631,29 @@ The following is much shorter:
|
||||
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
|
||||
The code generated for bswap on armv4/5 (CPUs without rev) is less than ideal:
|
||||
|
||||
int a(int x) { return __builtin_bswap32(x); }
|
||||
|
||||
a:
|
||||
mov r1, #255, 24
|
||||
mov r2, #255, 16
|
||||
and r1, r1, r0, lsr #8
|
||||
and r2, r2, r0, lsl #8
|
||||
orr r1, r1, r0, lsr #24
|
||||
orr r0, r2, r0, lsl #24
|
||||
orr r0, r0, r1
|
||||
bx lr
|
||||
|
||||
Something like the following would be better (fewer instructions/registers):
|
||||
eor r1, r0, r0, ror #16
|
||||
bic r1, r1, #0xff0000
|
||||
mov r1, r1, lsr #8
|
||||
eor r0, r1, r0, ror #8
|
||||
bx lr
|
||||
|
||||
A custom Thumb version would also be a slight improvement over the generic
|
||||
version.
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
|
Loading…
x
Reference in New Issue
Block a user