diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2010-07-15 02:20:38 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2010-07-15 02:20:38 +0000 |
commit | 4baa8ebc930407affeeba452ff75d20da73bf7f2 (patch) | |
tree | 8b0c9c1b14ed2c9ecd8026746e93aa36fa7750b3 | |
parent | b5b73c4c86b68e5edc3d3fceff28e852c1141b7f (diff) | |
download | external_llvm-4baa8ebc930407affeeba452ff75d20da73bf7f2.zip external_llvm-4baa8ebc930407affeeba452ff75d20da73bf7f2.tar.gz external_llvm-4baa8ebc930407affeeba452ff75d20da73bf7f2.tar.bz2 |
Random note about bswap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108396 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/README.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Target/ARM/README.txt b/lib/Target/ARM/README.txt index 83c4f67..0cb8ff0 100644 --- a/lib/Target/ARM/README.txt +++ b/lib/Target/ARM/README.txt @@ -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. + +//===---------------------------------------------------------------------===// |