From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28302 invoked by alias); 10 Feb 2003 07:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 28272 invoked by uid 71); 10 Feb 2003 07:56:00 -0000 Resent-Date: 10 Feb 2003 07:56:00 -0000 Resent-Message-ID: <20030210075600.28271.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, richard@wetafx.co.nz Received: (qmail 24403 invoked by uid 48); 10 Feb 2003 07:53:20 -0000 Message-Id: <20030210075320.24402.qmail@sources.redhat.com> Date: Mon, 10 Feb 2003 07:56:00 -0000 From: richard@wetafx.co.nz Reply-To: richard@wetafx.co.nz To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/9641: const double arguments and -ffloat-store do not work together X-SW-Source: 2003-02/txt/msg00445.txt.bz2 List-Id: >Number: 9641 >Category: optimization >Synopsis: const double arguments and -ffloat-store do not work together >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Feb 10 07:56:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: richard@wetafx.co.nz >Release: gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2) >Organization: >Environment: Linux 2.4.18-xfssmp #1 SMP i686 >Description: //////////main.c double rightfunc(double); double wrongfunc(double); int main(void) { rightfunc(0.75); wrongfunc(0.25); } //////////funcs.c double rightfunc(double t) { return t; } double wrongfunc(const double t) { return t; } //////////GNUmakefile all: wrong right right: main.c funcs.c; gcc -O3 -o $@ main.c funcs.c wrong: main.c funcs.c; gcc -O3 -ffloat-store -o $@ main.c funcs.c >How-To-Repeat: With the three supplied files, use gmake to build. The generated 'right' file works properly, but the generated 'wrong' file generates incorrect code for the 'wrongfunc' function: 0x8048474 : push %ebp 0x8048475 : mov %esp,%ebp 0x8048477 : sub $0x8,%esp 0x804847a : fldl 0xfffffff8(%ebp) 0x804847d : leave 0x804847e : ret 0x804847f : nop Basically, the code uses memory that has not be set to the value passed as a 'const double' argument. Note that rightfunc() has a double argument, while wrongfunc() has a const double argument. Otherwise they are the same. The 'wrong' file is built with -ffloat-store while the 'right' file is built without. >Fix: I can avoid 'const double' arguments, but this may mean some sifting through large code bases. I can avoid using -ffloat-store, but then I run into other code generation issues because of the broken nature how the optimizer handles comparisons with floats and doubles on Intel. >Release-Note: >Audit-Trail: >Unformatted: