This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

SH: 2.95.2/.3 miscompiles function


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;
}


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