summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-28 18:17:56 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-28 18:17:56 +0000
commitae37fadb1b713b93272d406e9f320edf3511ac6e (patch)
treef130708db0f14b92739a68669d38d745af58dc62
parent8cc8bb9bde265959ad69b3fc5cc84201461af1fb (diff)
downloadrockbox-ae37fadb1b713b93272d406e9f320edf3511ac6e.tar.gz
rockbox-ae37fadb1b713b93272d406e9f320edf3511ac6e.tar.bz2
rockbox-ae37fadb1b713b93272d406e9f320edf3511ac6e.zip
Submit FS#11502. Minor optimization to Coldfire assembler in libatrac's fixmul16(). Thanks to Nils Willménius.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27596 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libatrac/fixp_math.h27
1 files changed, 11 insertions, 16 deletions
diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h
index 8d2e0783b8..014c5aa559 100644
--- a/apps/codecs/libatrac/fixp_math.h
+++ b/apps/codecs/libatrac/fixp_math.h
@@ -60,25 +60,20 @@
lo; \
})
#elif defined(CPU_COLDFIRE)
+ /* Calculates: result = (X*Y)>>16 */
#define fixmul16(X,Y) \
({ \
- int32_t t1, t2; \
+ int32_t t, x = (X); \
asm volatile ( \
- "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \
- "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \
- "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \
- "moveq.l #15,%[t2] \n\t" \
- "asl.l %[t2],%[t1] \n\t" /* hi <<= 15, plus one free */ \
- "moveq.l #16,%[t2] \n\t" \
- "lsr.l %[t2],%[x] \n\t" /* (unsigned)lo >>= 16 */ \
- "or.l %[x],%[t1] \n\t" /* combine result */ \
- : /* outputs */ \
- [t1]"=&d"(t1), \
- [t2]"=&d"(t2) \
- : /* inputs */ \
- [x] "d" ((X)), \
- [y] "d" ((Y))); \
- t1; \
+ "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \
+ "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \
+ "movclr.l %%acc0,%[t] \n\t" /* get higher half */ \
+ "lsr.l #1,%[t] \n\t" /* hi >>= 1 to compensate emac shift */ \
+ "move.w %[t],%[x] \n\t" /* combine halfwords */\
+ "swap %[x] \n\t" \
+ : [t]"=&d"(t), [x] "+d" (x) \
+ : [y] "d" ((Y))); \
+ x; \
})
#define fixmul31(X,Y) \