From owner-freebsd-bugs Wed Nov 28 16:10: 9 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B5CE937B416 for ; Wed, 28 Nov 2001 16:10:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fAT0A1u43872; Wed, 28 Nov 2001 16:10:01 -0800 (PST) (envelope-from gnats) Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id 5E23D37B416 for ; Wed, 28 Nov 2001 16:01:48 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id LAA13087 for ; Thu, 29 Nov 2001 11:01:41 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01KB9VDJC5U8VFKI5H@cim.alcatel.com.au> for FreeBSD-gnats-submit@freebsd.org; Thu, 29 Nov 2001 11:00:54 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.6/8.11.6) id fAT013876664; Thu, 29 Nov 2001 11:01:03 +1100 (EST envelope-from jeremyp) Message-Id: <200111290001.fAT013876664@gsmx07.alcatel.com.au> Date: Thu, 29 Nov 2001 11:01:03 +1100 (EST) From: Peter Jeremy To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: gnu/32365: gcc optimiser bug with -O -march=i686 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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