This bug does not appear to occur with mspgcc4. The original source has to
be modified slightly so the unused assignment to b is not optimized away
entirely (add "volatile" as an scqualifier to the declaration of a and b),
but when this is done the generated code includes a second move of #100 into
__OP2.
Please try the latest release of mspgcc4. It is unlikely that the cause of
the problem will be isolated and back-ported to the 3.2.3 release.
Peter
On Fri, Feb 4, 2011 at 4:23 PM, Mike Van Emmerik <[email protected]> wrote:
> ( My apologies to the admins, who have seen this multiple times already. )
>
> Developers,
>
> I believe I've found a bug in msp430-gcc. I have no great interest in
> msp430-gcc development, just getting this
> particular bug fixed. So I'll likely unsubscribe soon.
>
> Version
> ======
>
> $ msp430-gcc --version
> msp430-gcc.exe (GCC) 3.2.3
> Copyright (C) 2002 Free Software Foundation, Inc. ...
>
> This likely came from mspgcc-20081230.exe .
>
> Test program:
> ==========
> int main(unsigned char x[]) {
> unsigned int a, b;
> a = x[0] * 100;
> b = x[1] * 100;
> return a;
> }
> ==========
> Compile command line (cygwin):
>
> msp430-gcc -mmcu=msp430x247 -Wall -O1 -S test.c
>
> (Bug does not happen with -O0)
>
> Incorrect output (trimmed)
> ==============
> push r2
> dint
> nop
> mov.b @r15, &__MPY
> mov.b #llo(100), &__OP2
> mov &__RESLO, r14
> pop r2
> push r2
> dint
> nop
> mov.b 1(r15), &__MPY // NOTE 1
> mov &__RESLO, r15
> pop r2
> mov r14, r15
> ==================
>
> Note the lack of assignment to __OP2 after NOTE 1 and before the
> result is read with __RESLO. It is not necessary to reload one of the
> OP1 registers (__MPY is one of these), but it IS necessary to load
> __OP2 to trigger the multiply process. The result of the multiply is
> not used in this simplified test program, but I assure you that this
> bug produces wrong behaviour in real-world code.
>
> It seems that gcc feels it can omit the second assignment to __OP2,
> since it already has the required value (immediate value 100).
> Somehow, gcc needs to be told that assignment to __OP2 has side
> effects, and cannot be optimised out.
>
> it seems that my bug is already in the system with this ID: 2082985
>
>
> http://sourceforge.net/tracker/index.php?func=detail&aid=2082985&group_id=42303&atid=432701
>
> I can only hope that my simpler example makes it easier to track down.
>
> - Mike
>
>
> ------------------------------------------------------------------------------
> The modern datacenter depends on network connectivity to access resources
> and provide services. The best practices for maximizing a physical server's
> connectivity to a physical network are well understood - see how these
> rules translate into the virtual world?
> http://p.sf.net/sfu/oracle-sfdevnlfb
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users