Shorten the coldfire fixmul32() by 2 instructions and use one register less. Smaller code, but practically no speed change.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13783 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c7c21ae03d
commit
5717a0af87
1 changed files with 21 additions and 21 deletions
|
@ -97,27 +97,27 @@ static fixed64 Fixed32To64(fixed32 x)
|
||||||
__result; \
|
__result; \
|
||||||
})
|
})
|
||||||
#elif defined(CPU_COLDFIRE)
|
#elif defined(CPU_COLDFIRE)
|
||||||
static inline int32_t fixmul32(int32_t x, int32_t y)
|
static inline int32_t fixmul32(int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
int32_t t1, t2;
|
#if PRECISION != 16
|
||||||
asm volatile (
|
#warning Coldfire fixmul32() only works for PRECISION == 16
|
||||||
"mac.l %[x],%[y],%%acc0\n" /* multiply */
|
#endif
|
||||||
"mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */
|
int32_t t1;
|
||||||
"movclr.l %%acc0,%[t1] \n" /* get higher half */
|
asm (
|
||||||
"moveq.l #15,%[t2] \n"
|
"mac.l %[x], %[y], %%acc0 \n" /* multiply */
|
||||||
"asl.l %[t2],%[t1] \n" /* hi <<= 15, plus one free */
|
"mulu.l %[y], %[x] \n" /* get lower half, avoid emac stall */
|
||||||
"moveq.l #16,%[t2] \n"
|
"movclr.l %%acc0, %[t1] \n" /* get higher half */
|
||||||
"lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 16 */
|
"lsr.l #1, %[t1] \n"
|
||||||
"or.l %[x],%[t1] \n" /* combine result */
|
"move.w %[t1], %[x] \n"
|
||||||
: /* outputs */
|
"swap %[x] \n"
|
||||||
[t1]"=&d"(t1),
|
: /* outputs */
|
||||||
[t2]"=&d"(t2),
|
[t1]"=&d"(t1),
|
||||||
[x] "+d" (x)
|
[x] "+d" (x)
|
||||||
: /* inputs */
|
: /* inputs */
|
||||||
[y] "d" (y)
|
[y] "d" (y)
|
||||||
);
|
);
|
||||||
return t1;
|
return x;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fixed32 fixmul32(fixed32 x, fixed32 y)
|
fixed32 fixmul32(fixed32 x, fixed32 y)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue