[llvm-commits] [compiler-rt] r107555 - in /compiler-rt/trunk/lib/arm: bswapdi2.S bswapsi2.S
John Tytgat
john at bass-software.com
Sat Jul 3 06:28:23 PDT 2010
In message <20100703010049.D01E92A6C12C at llvm.org>
Stephen Canon <scanon at apple.com> wrote:
> Author: scanon
> Date: Fri Jul 2 20:00:49 2010
> New Revision: 107555
>
> URL: http://llvm.org/viewvc/llvm-project?rev=107555&view=rev
> Log:
> Marginally smaller implementations of bswap for ARMv4, ARMv5 that avoid the need to establish a frame
>
> Modified:
> compiler-rt/trunk/lib/arm/bswapdi2.S
> compiler-rt/trunk/lib/arm/bswapsi2.S
This can be further optimised using a well known endian swap 4 instruction
idiom. Patch attached.
John.
--
John Tytgat
John at bass-software.com
-------------- next part --------------
Index: bswapdi2.S
===================================================================
--- bswapdi2.S (revision 107570)
+++ bswapdi2.S (working copy)
@@ -14,25 +14,23 @@
//
// Reverse all the bytes in a 64-bit integer.
//
- .align 2
+ .align 2
DEFINE_COMPILERRT_FUNCTION(__bswapdi2)
#if __ARM_ARCH_5TEJ__ || __ARM_ARCH_4T__
- mov r12, #0xff00
-
- and r3, r12, r0, lsr #8
- and r2, r12, r0
- orr r3, r3, r0, lsr #24
- orr r3, r3, r0, lsl #24
- orr r2, r3, r2, lsl #8 // r2 = rev(r0)
-
- and r3, r12, r1, lsr #8
- and r0, r12, r1
- orr r3, r3, r1, lsr #24
- orr r3, r3, r1, lsl #24
- orr r0, r3, r0, lsl #8 // r0 = rev(r1)
+ eor r2, r0, r0, ror #16
+ bic r2, r2, #0xff0000
+ mov r2, r2, lsr #8
+ eor r2, r2, r0, ror #8
+
+ eor r0, r1, r1, ror #16
+ bic r0, r0, #0xff0000
+ mov r0, r0, lsr #8
+ eor r0, r0, r1, ror #8
+
+ mov r1, r2
#else
- rev r2, r0 // r2 = rev(r0)
- rev r0, r1 // r0 = rev(r1)
+ rev r2, r0 // r2 = rev(r0)
+ rev r0, r1 // r0 = rev(r1)
#endif
- mov r1, r2 // r1 = r2 = rev(r0)
- bx lr
+ mov r1, r2 // r1 = r2 = rev(r0)
+ bx lr
Index: bswapsi2.S
===================================================================
--- bswapsi2.S (revision 107570)
+++ bswapsi2.S (working copy)
@@ -18,12 +18,10 @@
DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
#if __ARM_ARCH_5TEJ__ || __ARM_ARCH_4T__
// before armv6 does not have "rev" instruction
- mov r1, #0xff00
- and r2, r1, r0, lsr #8
- and r1, r1, r0
- orr r2, r2, r0, lsr #24
- orr r2, r2, r0, lsl #24
- orr r0, r2, r1, lsl #8
+ eor r1, r0, r0, ror #16
+ bic r1, r1, #0xff0000
+ mov r1, r1, lsr #8
+ eor r0, r1, r0, ror #8
#else
rev r0, r0 // reverse bytes in parameter and put into result register
#endif
More information about the llvm-commits
mailing list