From mboxrd@z Thu Jan 1 00:00:00 1970 From: hjl@lucon.org (H.J. Lu) To: acs@alumni.princeton.edu Cc: jinbo21@soback.kornet.nm.kr, egcs@cygnus.com Subject: Re: Different Test Results w/ -march=pentiumpro Date: Thu, 07 May 1998 19:33:00 -0000 Message-id: References: <199805070316.XAA18129@spacely.icd.teradyne.com> X-SW-Source: 1998-05/msg00260.html > > On my UnixWare 2.1.2 (i386-pc-sysv4.2uw2.1.2) system with the 0502 snapshot, > I get different test results when I add -march=pentiumpro to BOOT_CFLAGS. > > In the first case I built with: > BOOT_CFLAGS='-O3 -malign-jumps=4 -malign-loops=4 -malign-functions=4' > > while in the second, I added -march=pentiumpro: > BOOT_CFLAGS='-O3 -march=pentiumpro -malign-jumps=4 -malign-loops=4 -malign-functions=4' > > > Here are the diffs in the summaries: > > diff ~/tmp/egcs-19980502.results egcs-19980502.results-ppro > 43a44,48 > > FAIL: gcc.c-torture/execute/loop-4.c execution, -O2 > > FAIL: gcc.c-torture/execute/loop-4.c execution, -O2 -fomit-frame-pointer -finline-functions > > FAIL: gcc.c-torture/execute/loop-4.c execution, -O2 -fomit-frame-pointer -finline-functions -funroll-loops > > FAIL: gcc.c-torture/execute/loop-4.c execution, -O2 -fomit-frame-pointer -finline-functions -funroll-all-loops > > FAIL: gcc.c-torture/execute/loop-4.c execution, -O2 -g There is a bug between final_scan_insn () and notice_update_cc () on x86. final_scan_insn () may optimize out a test/compare instruction when egcs thinks the condition code is already set up as desired. The problem is notice_update_cc on x86 will update the condition code for all kinds of instructions, including subl %ecx,%eax For subl %ecx,%eax movl %eax,0xffffffd4(%ebp) testl %eax,%eax when egcs sees "testl %eax,%eax", it knows the condition code is changed by "subl %ecx,%eax" and "testl %eax,%eax" is ignored. Now we get a problem. Since "subl %ecx,%eax" may cause overflow, the condition code will be bogus in this case. Because of this, check_dbra_loop () is miscompiled for PPro. One way to fix it is to disable the condition code optimization. Or we can add a bit to cc_status.flags, CC_UPDATED_BY_TEST_COMPARE. We set the CC_UPDATED_BY_TEST_COMPARE bit in NOTICE_UPDATE_CC and final_scan_insn () check the CC_UPDATED_BY_TEST_COMPARE bit before optimizing out the condition code. BTW, this bug may be cpu independent and may exist in egcs 1.0.x. We just happen to see egcs itself be miscompiled this time. H.J.