Hello. Sorry if the summary is a little vague, I dont really know a whole bunch about gcc terminology ;) So anyway, I wrote a simple program in C that computes the factorials of numbers 1 through 100 (yes, after 7 they get super big). When this program is compiled as gcc -ffast-math factorial.c I get an ICE; paul@nephilim:~/c$ gcc -Wall -ffast-math factorials.c factorials.c:8: warning: return type defaults to ‘int’ factorials.c: In function ‘main’: factorials.c:24: internal compiler error: in instantiate_virtual_regs_lossage, at function.c:1442 paul@nephilim:~/c$ gcc -dumpversion 4.0.2 This gcc is from Ubuntu-breezy, gcc-4.0 branch, CVS 20050718. Running on a Pentium 4. It told me to report this bug, so here I am :) Regardless of whether this can be done in a simpler manner, and I'm /sure/ it can, I dont think gcc should die because of it. The offending code is attached. -save-temps output also attached.
Created attachment 9309 [details] bug causing program...
Created attachment 9310 [details] -save-temps output
Created attachment 9311 [details] -save-temps output
If it is at all relevant, I'm using the glibc that breezy provides (2.3.5).
This is a target bug.
Created attachment 9312 [details] #included file
Reduced testcase: ======================== int foo(long double d) { return d==0; } ======================== Comparison of long doubles with zero seems to be a problem. This is a regression from gcc 3.4.x.
Comment on attachment 9309 [details] bug causing program... >#include <stdio.h> > >/* Program prints the first 10 postitive integers and their factorials */ > >main() >{ >long double i, j, k = 1; > >for(i = 1; i <= 100; i++) > { > for(j = i; j > 0; j = j - 1) > { > k = k * j; > if(j == 1) > { > printf("factorial of %Lf is %Lf\n", i, k); > k = 1; > } > } > } > return 0; >}
Patch that fixes attached testcase and reduced testcase from comment #7. BTW: In the attached testcase, there is a comment that program falls apart if long double isn't used. With (patched) gcc-4.1 CVS, it works for me with "only" doubles, with SSE or x87 math, -ffast-math or without it. ... factorial of 99 is 9.33262e+155 factorial of 100 is 9.33262e+157
The problem is related to PR22585 where another ICE with long doubles occurs. Unfortunately Uros' patch doesn't fix the problem there.
Subject: Bug 22576 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2005-07-21 19:55:03 Modified files: gcc : ChangeLog gcc/config/i386: i386.md Log message: PR target/22576 * config/i386/i386.md (cmpxf): Change operand constraints to "nonmemory_operand". Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9504&r2=2.9505 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.649&r2=1.650
Subject: Bug 22576 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: rth@gcc.gnu.org 2005-07-21 19:56:30 Modified files: gcc : ChangeLog gcc/config/i386: i386.md Log message: PR target/22576 * config/i386/i386.md (cmpxf): Change operand constraints to "nonmemory_operand". Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.325&r2=2.7592.2.326 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.618.4.4&r2=1.618.4.5
Fixed.
Subject: Bug 22576 CVSROOT: /cvs/gcc Module name: gcc Changes by: janis@gcc.gnu.org 2005-09-26 19:19:43 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.target/i386: pr22576.c pr22585.c pr23268.c builtin-apply-mmx.c Log message: 2005-08-26 Uros Bizjak <uros@kss-loka.si> * gcc.target/i386/builtin-apply-mmx.c: New test. PR target/22576 * gcc.target/i386/pr22576.c: New test. PR target/22585 * gcc.target/i386/pr22585.c: New test. PR target/23268 * gcc.target/i386/pr23268.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6104&r2=1.6105 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr22576.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr22585.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr23268.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 22576 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: uros@gcc.gnu.org 2005-10-07 05:32:37 Modified files: gcc : ChangeLog gcc/config/i386: i386.c sse.md gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.target/i386: pr22576.c pr22585.c pr23570.c Log message: PR target/23570 * config/i386/sse.md (*sse_concatv2sf): Change operand 2 constraint to "reg_or_0_operand". (sse2_loadld): Change operand 1 constraint to "reg_or_0_operand". testsuite/ PR target/22576 * gcc.target/i386/pr22576.c: New test. PR target/22585 * gcc.target/i386/pr22585.c: New test. PR target/23570 * gcc.target/i386/pr23570.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.451&r2=2.7592.2.452 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.795.6.11&r2=1.795.6.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/sse.md.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.7.14.2&r2=1.7.14.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.434&r2=1.5084.2.435 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr22576.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.10.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr22585.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.2.10.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr23570.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.20.1