Stephen,
This appears to be a bug in the IR Optimizer (opts on). I think you
are correct, it should be muls.w. I will log this bug. In the meantime, I
would suggest a couple extra lines of code to work around this bug:
unsigned long test (unsigned long x, signed short y, signed short z)
{
unsigned long tm;
signed long f;
f = (signed long) (y - z) * 10;
tm = x + f;
return tm;
}
We apologize for this inconvenience.
Jun-Kiat Lam
Metrowerks Technical Support
----- Original Message -----
From: "Stephen Best" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Tuesday, February 15, 2000 8:28 PM
Subject: CW6 optimizer bug?
> Given the logic below, what would you expect for result?
>
> unsigned long test (unsigned long x, signed short y, signed short z)
> {
> return x + (signed long) (y - z) * 10;
> }
>
> result = test (10, 0, 1);
>
> CW5, CW6 (Optimization level 0) and VC++ 5.0 all give result = 0.
> CW6 (Optimization levels 1-4) give result = 655360 (0x000a0000).
>
> The suspect code generated is:
>
> move.w 12(a6),d0
> sub.w 14(a6),d0
> mulu.w #10,d0 <---- should be muls.w?
> add.l 8(a6),d0
>
> Stephen Best
> Bitware Australia
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html