Date: Thu, 29 Nov 2001 11:01:03 +1100 (EST) From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: FreeBSD-gnats-submit@freebsd.org Subject: gnu/32365: gcc optimiser bug with -O -march=i686 Message-ID: <200111290001.fAT013876664@gsmx07.alcatel.com.au>
next in thread | raw e-mail | index | archive | help
>Number: 32365
>Category: gnu
>Synopsis: gcc optimiser bug with -O -march=i686
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 28 16:10:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Peter Jeremy
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
Alcatel Australia Limited
>Environment:
System: FreeBSD gsmx07.alcatel.com.au 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Mon Nov 26 08:22:11 EST 2001 root@gsmx07.alcatel.com.au:/usr/obj/3.0/cvs/src/sys/gsmx i386
This bug also appears in a recent 4-STABLE.
>Description:
gcc generates incorrect code for the program below when compiled
with options "-O -march=i686". The problem appears to be an
incorrect assumption in gcc/config/i386/i386.c:notice_update_cc()
which assumes that moves don't affect condition codes. The
double arguments are passed using movdf_push, but the IA32
doesn't have a floating point push, so this is implemented as
a store followed by a stack pointer adjustment - which does
affect CC. Changing all the floating point constants/arguments
to integer removes the bug.
This showed up building the gnuplot port. I don't know if
it affects anything in the base system.
>How-To-Repeat:
Save the following code as x.c and compile with
"/usr/libexec/cc1 -O -march=i686 -quiet x.c"
---
int x;
void foo(double, double);
void bar()
{
foo(x?1.5:1.0, x?1.5:1.0);
}
---
This results in the following assember (annotations added by me):
---
.file "x.c"
.version "01.01"
gcc2_compiled.:
.section .rodata
.p2align 3
.LC0:
.long 0x0,0x3ff80000
.text
.p2align 2,0x90
.globl bar
.type bar,@function
bar:
pushl %ebp
movl %esp,%ebp
subl $8,%esp
fld1
movl x,%eax
fldl .LC0
fld %st(1)
testl %eax,%eax <-- this is the "x?" part of the code.
fcmovne %st(1),%st
subl $8,%esp <-- this destroys CC from the above testl
fstpl (%esp)
fcmove %st(1),%st <-- this assumes the testl CC is still valid
fstp %st(1)
subl $8,%esp
fstpl (%esp)
call foo
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size bar,.Lfe1-bar
.comm x,4,4
.ident "[ASM_FILE_END]GCC: (c) 2.95.3 20010315 (release)"
---
>Fix:
Not known at this time.
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111290001.fAT013876664>
