SH: 2.95.2/.3 miscompiles function

Schirmer, Hartmut HSchirmer@Innovative-Systems.de
Fri May 17 04:15:00 GMT 2002


Hi,

the test case below triggers a bug in gcc 2.95.2 & 2.95.3
for sh-hitachi-coff (cross from cygwin / nt4)

The bug only occurs with -Os

Using gcc 3.1 the code looks ok

Hartmut

/*
	This testcase fails for sh-hitachi-coff
	using gcc-2.95.2/.3 -mrelax -m3 -ansi -g -Os -fno-keep-static-consts
-fno-strict-aliasing -fno-gcse

      test() is miscompiled:

	mov.l	L4,r1			// load 32678 to r1
	cmp/eq	#1,r0
	bf.s	L3
	mov	r15,r14
	sts	macl,r1		// reading macl without mul ...
L3:
*/

long test (int bar)
{
    long r;
    r = 32768;  
    if ( 1 == bar )
    {
        r *= 8;  
    }
    return r;
}

int main()
{
    if ( 32768 != test(0) )
        abort();
    if ( 32768*8 != test(1) )
        abort();
    return 0;
}



More information about the Gcc-bugs mailing list