linux-mips
[Top] [All Lists]

Re: Optimisation

To: Sridhar Adagada <asridhars@gmail.com>
Subject: Re: Optimisation
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Thu, 8 Jul 2004 10:59:58 +0200 (MEST)
Cc: Linux/MIPS Development <linux-mips@linux-mips.org>
In-reply-to: <f013fac60407072338b65f8fd@mail.gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <f013fac60407072338b65f8fd@mail.gmail.com>
Sender: linux-mips-bounce@linux-mips.org
On Thu, 8 Jul 2004, Sridhar Adagada wrote:
> As you can see $6 is the length, my confusion is at the lines 12-14,
> 19, 20 why is the length added with 65535 and the comparison with 0

It's not `added with 65535', but `ANDed with 65535'. MIPS32 has 32-bit integer
operations only. If you want to do 16-bit math, all data has to be masked.

Anyway, for performance, it's better to do 32-bit math only.

> short cal_xxx(short *abs, short *coef, short len, short base)
> {
>  short i;
>  short sum = 0;
>
>  for (i = 0; i < length; i++)
>  {
>    sum += ( (unsigned int)abs[i] * (unsigned int)coef[i] );

Why cast to unsigned int while sum is a short? Unless you really want to rely
on sum being a short, you better make it int and do the truncation to short
after the loop.

Gr{oetje,eeting}s,

                                                Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                            -- Linus Torvalds

<Prev in Thread] Current Thread [Next in Thread>