From ae37fadb1b713b93272d406e9f320edf3511ac6e Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Wed, 28 Jul 2010 18:17:56 +0000 Subject: Submit FS#11502. Minor optimization to Coldfire assembler in libatrac's fixmul16(). Thanks to Nils Willménius. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27596 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libatrac/fixp_math.h | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'apps') 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) \ -- cgit v1.2.3