[llvm-commits] [llvm] r108396 - /llvm/trunk/lib/Target/ARM/README.txt
Eli Friedman
eli.friedman at gmail.com
Wed Jul 14 19:20:38 PDT 2010
Author: efriedma
Date: Wed Jul 14 21:20:38 2010
New Revision: 108396
URL: http://llvm.org/viewvc/llvm-project?rev=108396&view=rev
Log:
Random note about bswap.
Modified:
llvm/trunk/lib/Target/ARM/README.txt
Modified: llvm/trunk/lib/Target/ARM/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=108396&r1=108395&r2=108396&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/README.txt (original)
+++ llvm/trunk/lib/Target/ARM/README.txt Wed Jul 14 21:20:38 2010
@@ -631,3 +631,29 @@
//===---------------------------------------------------------------------===//
+
+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.
+
+//===---------------------------------------------------------------------===//
More information about the llvm-commits
mailing list