mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Random note about bswap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108396 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b5b73c4c86
commit
4baa8ebc93
@ -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…
Reference in New Issue
Block a user