This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Wrong code generated for Hitachi SH


Hello,

I have a problem when cross-compiling for sh-coff. The following program

unsigned int test(unsigned int x)
{
  return 1000 + x;
}

yields the following result when compiling with -O2:
/opt/cgcc/bin/sh-coff-gcc -fomit-frame-pointer -m3 -O2 -S hello.c
        .file   "hello.c"
        .data
gcc2_compiled.:
___gnu_compiled_c:
        .text
        .align 4
        .global _test
_test:
        mov.w   L3,r0
        rts
        nop
        .align 1
L3:
        .short  1000

As you can see, the addition is never performed - the routine always returns
1000. 

(leaving out -fomit-frame-pointer or -m3 changes nothing, and with -O1 the
output is fine).

This happens with both gcc-2.95.2 and the 20000221 snapshot (the 20000230
snapshot does not compile). egcs 1.1b did not have this problem. The same
compiler, built for a powerpc-eabi target, produced correct code.

This happens both on a linux-i686 and a cygwin host.

Any ideas?

cu
Michael
-- 
In the beginning there was nothing, which exploded.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]