Bug 11637 - [3.3/3.4 Regression]g++ invalid assembly with -fnon-call-exceptions
Summary: [3.3/3.4 Regression]g++ invalid assembly with -fnon-call-exceptions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P1 critical
Target Milestone: 3.3.2
Assignee: Eric Botcazou
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-07-22 22:26 UTC by nick
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-07-22 22:43:08


Attachments
preprocessed source triggering bug (96.25 KB, text/plain)
2003-07-22 22:28 UTC, nick
Details
resulting assembly from the compiler (1.12 KB, text/plain)
2003-07-22 22:29 UTC, nick
Details
better testcase with no iostream dependancy (98 bytes, text/plain)
2003-07-22 22:55 UTC, nick
Details
assembly output from better testcase (494 bytes, text/plain)
2003-07-22 22:56 UTC, nick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nick 2003-07-22 22:26:48 UTC
using the gcc-3.3.1-20030720 prerelease,
binutils-2.4
the following code 

----
#include <iostream>

void foo(float f);

void
split1()
{
    std::cout << .1f ;
    foo(.1f);
}
---

causes:

> /dept/rnd/vendor/gcc-3.3.1-20030720/bin/g++ -fnon-call-exceptions -O2 -c
asmbug.C -o /dev/null
/usr/tmp/cchhQIen.s: Assembler messages:
/usr/tmp/cchhQIen.s:25: Error: junk `.00000001490116119384766e-1' after expression
/usr/tmp/cchhQIen.s:25: Error: too many memory references for `mov'


the assembly generated for split1 is:

---
.globl _Z6split1v
        .type   _Z6split1v, @function
_Z6split1v:
.LFB1607:
        pushl   %ebp
.LCFI0:
        movl    %esp, %ebp
.LCFI1:
        subl    $24, %esp
.LCFI2:
        flds    .LC1
        movl    $_ZSt4cout, (%esp)
        fstpl   4(%esp)
        call    _ZNSolsEd
        movl    1.00000001490116119384766e-1, (%esp)
        call    _Z3foof
        movl    %ebp, %esp
        popl    %ebp
        ret
---

I'll attach preprocessed source and resulting assembly to the bug.

-nick
Comment 1 nick 2003-07-22 22:28:46 UTC
Created attachment 4456 [details]
preprocessed source triggering bug
Comment 2 nick 2003-07-22 22:29:26 UTC
Created attachment 4457 [details]
resulting assembly from the compiler
Comment 3 Andrew Pinski 2003-07-22 22:43:08 UTC
This looks like a bad regression I can reproduce it on the mainline (20030719)  and 3.3.1 
(20030707).  I think the problem is only when printing out the floating point number.
There might be a way to construct a testcase which does not use -fnon-call-exceptions.
Comment 4 nick 2003-07-22 22:55:32 UTC
Created attachment 4458 [details]
better testcase with no iostream dependancy
Comment 5 nick 2003-07-22 22:56:15 UTC
Created attachment 4459 [details]
assembly output from better testcase
Comment 6 Andrew Pinski 2003-07-23 03:47:31 UTC
The simplified example does not show the problem on the mainline (20030719) but it 
does show the problem in 3.3.1 (20030707).
Comment 7 janis187 2003-07-25 23:07:27 UTC
The regression in PR 11637 was introduced or exposed with this patch:

--- gcc/gcc/ChangeLog ---

2002-11-17  Graham Stott  <graham.stott@btinternet.com>

        * real.c (real_to_decimal): Fix buffer overrun when buffer size
        is smaller than representation.

It is still broken on the 3.3-branch but was fixed on mainline by:

--- gcc/gcc/ChangeLog ---

Tue Jan 14 00:45:33 CET 2003  Jan Hubicka  <jh@suse.cz>

        * convert.c (strip_float_extensions):  Look for narrowest type handling
        FP constants.

        * fold-const.c (fold):  Fold (double)float1 CMP (double)float2 into
        float1 CMP float2.
        * convert.c (strip_float_extensions): Make global.
        * tree.h (strip_float_extensions): Declare.

The regression hunt was done on i686-pc-linux-gnu using the small test
case compiled with "-O2 -fnon-call-exceptions, and then searching the
generated .s file for "3e-2".
Comment 8 Mark Mitchell 2003-08-03 16:02:36 UTC
Postponed until GCC 3.3.2.
Comment 9 Eric Botcazou 2003-09-13 07:17:44 UTC
Fixing.
Comment 11 Mark Mitchell 2003-10-05 18:22:47 UTC
Subject: Re:  [3.3/3.4 Regression]g++ invalid
	assembly with -fnon-call-exceptions

On Fri, 2003-10-03 at 23:17, ebotcazou at gcc dot gnu dot org wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11637

This patch is OK, with one caveat: I don't understand why it's necessary
to remove REG_NOALIAS notes.  If that's not necessary to fix the test
case in question, please omit that one part of the patch.  If it is
necessary, go ahead and check in the patch, but please explain what's
going wrong there.

(The docs say that REG_NOALIAS is attached to call instructions, and
here I thought we were always looking a SET.)

Thanks,

Comment 12 Eric Botcazou 2003-10-06 06:43:40 UTC
You're right, removing REG_NOALIAS notes is not necessary. I included it because
the first version of the patch (which was messy) tweaked distribute_notes instead,
and distribute_notes treats the 3 kinds of notes the same way.

I'll remove it. Thanks for the review.
Comment 13 CVS Commits 2003-10-06 08:52:30 UTC
Subject: Bug 11637

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2003-10-06 08:52:23

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: float1.C 

Log message:
	2003-10-06  Eric Botcazou  <ebotcazou@libertysurf.fr>
	
	PR optimization/11637
	* combine.c (adjust_for_new_dest): New function to adjust the
	notes and LOG_LINKS when the dest of an insn has changed.
	(try_combine): Use it when deleting the first insn of a two-insn
	parallel or splitting a two-load parallel.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1296&r2=2.1297
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&r1=1.389&r2=1.390
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3096&r2=1.3097
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/float1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 14 CVS Commits 2003-10-06 08:59:05 UTC
Subject: Bug 11637

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	ebotcazou@gcc.gnu.org	2003-10-06 08:59:02

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: float1.C 

Log message:
	PR optimization/11637
	* combine.c (adjust_for_new_dest): New function to adjust the
	notes and LOG_LINKS when the dest of an insn has changed.
	(try_combine): Use it when deleting the first insn of a two-insn
	parallel or splitting a two-load parallel.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.771&r2=1.16114.2.772
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.325.2.13&r2=1.325.2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.297&r2=1.2261.2.298
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/float1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 15 Eric Botcazou 2003-10-06 09:00:23 UTC
Patch applied with Mark's correction.