Bug 12092 - ICE: Floating point exception
Summary: ICE: Floating point exception
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 9971 17710 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-28 09:47 UTC by Wout Mertens
Modified: 2005-01-02 00:19 UTC (History)
4 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: 2004-12-28 02:12:11


Attachments
Preprocessed source (28.96 KB, text/plain)
2003-08-28 09:48 UTC, Wout Mertens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wout Mertens 2003-08-28 09:47:13 UTC
configured with: /var/tmp/portage/gcc-3.3.1/work/gcc-3.3.1/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++,ada,f77,objc --enable-threads=posix --enable-long-long
--disable-checking --enable-cstdio=stdio --enable-clocale=generic
--enable-__cxa_atexit --enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --disable-multilib

System is a Pentium 4.

When compiling gst-plugins, I get a floating point exception. I'll attach the
preprocessed source.

gcc -DHAVE_CONFIG_H -I. -I. -I../.. -O3 -mcpu=i486 -fschedule-insns2
-funroll-all-loops -finline-functions -ffast-math -DNDEBUG -I../../gst-libs
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -pthread -I/usr/include/gstreamer-0.6
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2
-DGST_DISABLE_DEPRECATED -g -O2 -march=pentium4 -fprefetch-loop-arrays -pipe -c
codec.c -MT libgstmpeg1encoder_la-codec.lo -MD -MP -MF
.deps/libgstmpeg1encoder_la-codec.TPlo  -fPIC -DPIC -o
libgstmpeg1encoder_la-codec.lo
codec.c: In function `DecodeAC':
codec.c:286: internal compiler error: Floating point exception
Comment 1 Wout Mertens 2003-08-28 09:48:48 UTC
Created attachment 4669 [details]
Preprocessed source
Comment 2 Wout Mertens 2003-08-28 10:24:30 UTC
When I compile with 
CFLAGS="-O2 -march=pentium4 -pipe"

it doesn't ICE.
Comment 3 Andrew Pinski 2003-08-28 12:51:04 UTC
Most likely the same bug as PR 9971 but with a different code.
Comment 4 Andrew Pinski 2003-08-28 13:00:53 UTC
I can confirm this on the mainline (20030827).
Reduced source:
void DecodeAC(int index,int *matrix)
{
  int *mptr;

  for(mptr=matrix+index;mptr<matrix+64;mptr++) {*mptr = 0;}
}
Comand line: gcc  -funroll-all-loops -ffast-math -O2 -mtune=i486 -march=pentium4 -
fprefetch-loop-arrays pr12092.c.
Comment 5 Andrew Pinski 2003-08-28 13:02:01 UTC
*** Bug 9971 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2003-08-29 16:30:23 UTC
Something here is causing it:
From loop.c:
4030          /* Prefetch might be worthwhile only when the loads/stores are dense.  */
4031          if (PREFETCH_ONLY_DENSE_MEM)
4032            if (density * 256 > PREFETCH_DENSE_MEM * 100
4033                && (info[i].total_bytes / PREFETCH_BLOCK                        <--- I want to say 
this guy is causing it
4034                    >= PREFETCH_BLOCKS_BEFORE_LOOP_MIN))

And it is PREFETCH_BLOCK is defined as ix86_cost->prefetch_block which is zero at 
this point because we are tuning for i486 (which does not have prefetch at all) but our 
arch is pentium4 which does have prefetch so we try to use prefetch but we need to 
figure out if it is good to prefetch so we do a divide on PREFETCH_BLOCK but since 
PREFETCH_BLOCK is zero here, we get an floating exception.
Comment 7 Andrew Pinski 2003-09-01 04:34:36 UTC
I think this patch will fix it but I have no way to test it as bootstrap fails for me before 
applying the patch (once GCC gets back bootstrapping, I will submit this):
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.469
diff -u -d -b -w -u -p -r1.469 loop.c
--- loop.c      30 Jul 2003 20:28:45 -0000      1.469
+++ loop.c      1 Sep 2003 04:32:20 -0000
@@ -4029,7 +4029,7 @@ emit_prefetch_instructions (struct loop 
 
       /* Prefetch might be worthwhile only when the loads/stores are dense.  */
       if (PREFETCH_ONLY_DENSE_MEM)
-       if (density * 256 > PREFETCH_DENSE_MEM * 100
+       if (PREFETCH_BLOCK != 0 && density * 256 > PREFETCH_DENSE_MEM * 100
            && (info[i].total_bytes / PREFETCH_BLOCK
                >= PREFETCH_BLOCKS_BEFORE_LOOP_MIN))
          {
@@ -4050,7 +4050,7 @@ emit_prefetch_instructions (struct loop 
        info[i].prefetch_in_loop = 1, info[i].prefetch_before_loop = 1;
 
       /* Find how many prefetch instructions we'll use within the loop.  */
-      if (info[i].prefetch_in_loop != 0)
+      if (info[i].prefetch_in_loop != 0 && PREFETCH_BLOCK != 0)
        {
          info[i].prefetch_in_loop = ((info[i].stride + PREFETCH_BLOCK - 1)
                                  / PREFETCH_BLOCK);
@@ -4085,7 +4085,7 @@ emit_prefetch_instructions (struct loop 
        info[i].prefetch_in_loop = 0;
 
       /* Find how many prefetch instructions we'll use before the loop.  */
-      if (info[i].prefetch_before_loop != 0)
+      if (info[i].prefetch_before_loop != 0) && PREFETCH_BLOCK != 0
        {
          int n = info[i].total_bytes / PREFETCH_BLOCK;
          if (n > ahead)
Comment 8 Andrew Pinski 2003-09-08 06:06:21 UTC
A new version of the patch which works and submitted: <http://gcc.gnu.org/ml/gcc-
patches/2003-09/msg00449.html>
Comment 9 Kelley Cook 2003-09-09 20:18:37 UTC
A different question is shouldn't -march=pentium4 -mtune=i486 be declared invalid?

To me, tuning (ie scheduling) for a processor that is less than the baseline
architecture (which -march specifies) just seems wrong.

The 486 didn't know about SSE2, it didn't know about SSE, it didn't know about
MMX, it didn't even know about CMOV, but by specifying -march=pentium4 all of
those features are enabled.  So, there is no way for the scheduler to come up
with a correct schedule.
Comment 10 Zack Weinberg 2003-12-02 00:47:18 UTC
Please revise your patch according to Jim's suggestions and resubmit.
Comment 11 Andrew Pinski 2004-02-08 06:35:32 UTC
Not working on updating the patch (too much others things to do).
Comment 12 Andrew Pinski 2004-09-28 13:00:39 UTC
*** Bug 17710 has been marked as a duplicate of this bug. ***
Comment 13 CVS Commits 2005-01-02 00:15:14 UTC
Subject: Bug 12092

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2005-01-02 00:15:01

Modified files:
	gcc            : ChangeLog loop.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr12092-1.c 

Log message:
	PR rtl-optimization/12092
	* loop.c (emit_prefetch_instructions): Do nothing if PREFETCH_BLOCK
	is zero.
	
	* gcc.dg/pr12092-1.c: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6998&r2=2.6999
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&r1=1.518&r2=1.519
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4832&r2=1.4833
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr12092-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 14 Andrew Pinski 2005-01-02 00:19:53 UTC
Fixed in 4.0.0.
Comment 16 CVS Commits 2005-01-03 03:34:04 UTC
Subject: Bug 12092

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hp@gcc.gnu.org	2005-01-03 03:33:58

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg: pr12092-1.c 

Log message:
	PR rtl-optimization/12092
	* gcc.dg/pr12092-1.c: Fix typo in dg directive.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4836&r2=1.4837
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr12092-1.c.diff?cvsroot=gcc&r1=1.2&r2=1.3