( 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

Reply via email to