Bug 17428 - internal compiler error: in spill_failure, at reload1.c:1880 (-fspeculative-prefetching)
: internal compiler error: in spill_failure, at reload1.c:1880 (-fspeculative-p...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: rtl-optimization
: 4.0.0
: P1 normal
: 4.0.0
Assigned To: Jan Hubicka
:
: build, ice-on-valid-code, patch
:
: 17491
  Show dependency treegraph
 
Reported: 2004-09-12 03:41 UTC by Tim Savannah
Modified: 2005-07-29 09:42 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.2
Known to fail:
Last reconfirmed: 2005-02-26 18:42:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Savannah 2004-09-12 03:41:30 UTC
error in gcc version 4.0.0 20040912 (experimental).

Error occured when compiling gcc with itself (during Bootstrapping training
compiler) using the following configure command:


 ../gcc/configure --prefix=/beta/ --enable-shared --enable-languages=c,c++,objc
--enable-threads=posix --enable-__cxa_atexit --disable-libgcj --enable-libada

and the following make command:

export CFLAGS="-mmmx -msse -msse2 -march=pentium4 -mfpmath=sse
-maccumulate-outgoing-args  -O2 -fgcse-after-reload -fmodulo-sched -fweb
-funroll-loops -fprefetch-loop-arrays -floop-optimize2 -fsched-spec-load
-ftree-loop-linear -ftree-vectorize -fomit-frame-pointer -pipe -s"

make BOOT_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STAGE1_CFLAGS="$CFLAGS"
profiledbootstrap

on gcc/gengtype.c, the compiler fails with:

stage1/xgcc -Bstage1/ -B/beta//i686-pc-linux-gnu/bin/ -c   -mmmx -msse -msse2
-march=pentium4 -mfpmath=sse -maccumulate-outgoing-args  -O2 -fgcse-after-reload
-fmodulo-sched -fweb -funroll-loops -fprefetch-loop-arrays -floop-optimize2
-fsched-spec-load -ftree-loop-linear -ftree-vectorize -fomit-frame-pointer -pipe
-s -save-temps -fprofile-generate -DIN_GCC   -W -Wall -Wwrite-strings
-Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long
-Wno-variadic-macros -Wold-style-definition -Werror -fno-common  
-DHAVE_CONFIG_H -DGENERATOR_FILE    -I. -I. -I../../gcc/gcc -I../../gcc/gcc/.
-I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include  \
    ../../gcc/gcc/gengtype.c -o gengtype.o

../../gcc/gcc/gengtype.c: In function `finish_root_table':
../../gcc/gcc/gengtype.c:2501: error: unable to find a register to spill in
class `AD_REGS'
../../gcc/gcc/gengtype.c:2501: error: this is the insn:
(insn:HI 987 82 988 113 (parallel [
            (set (reg:DI 486 [ ivtmp.762 ])
                (sign_extend:DI (reg/f:SI 60 [ ivtmp.762 ])))
            (clobber (reg:CC 17 flags))
            (clobber (scratch:SI))
        ]) 85 {*extendsidi2_1} (nil)
    (expr_list:REG_UNUSED (scratch:SI)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (expr_list:REG_UNUSED (scratch:SI)
                (expr_list:REG_UNUSED (reg:CC 17 flags)
                    (nil))))))
../../gcc/gcc/gengtype.c:2501: internal compiler error: in spill_failure, at
reload1.c:1880
Please submit a full bug report,
with preprocessed source if appropriate.



the gengtype.i was rather large, so instead of pasting it here it can be found at:

http://linux-militia.net/kernel/stuff/gengtype.i
Comment 1 Tim Savannah 2004-09-12 03:45:55 UTC
I should also note that it works with CFLAGS as -O2, but fails with -O2
-march=pentium4, so it looks like -march=pentium4 is the culprit..
Comment 2 Andrew Pinski 2004-09-12 03:54:45 UTC
*** Bug 17429 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2004-09-12 03:54:48 UTC
*** Bug 17430 has been marked as a duplicate of this bug. ***
Comment 4 Volker Reichelt 2004-09-14 02:13:16 UTC
Here's a reduced testcase.
It crashes when compiled with "gcc -msse -O2 -fprofile-generate"

======================================
int a[2];

static void foo(int i, int j)
{
  while (1) ;
}

void bar()
{
  int i;

  for (i=0; i<2; ++i)
    foo(a[i],0);
  foo(0,0);
}
======================================

Phil's regression hunter states:
: Search converges between 2004-09-05-trunk (#534) and 2004-09-06-trunk (#535).
Comment 5 Andrew Pinski 2004-09-14 02:32:21 UTC
I would assume that this is caused by:
2004-09-05  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>

        * tree-ssa-loop-ivopts.c: New file.
	....

But then again this most likely can be produced ealier than that or maybe not.

One thing I noticed though is that "&a[0] + 8B" not folded to &a[2] which might improve the issue.
Comment 6 Zdenek Dvorak 2004-09-14 21:09:38 UTC
Subject: Re:  [4.0 Regression] internal compiler error: in spill_failure, at
reload1.c:1880

Hello,

> I would assume that this is caused by:
> 2004-09-05  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
> 
>         * tree-ssa-loop-ivopts.c: New file.
> 	....
> 
> But then again this most likely can be produced ealier than that or maybe not.
> 
> One thing I noticed though is that "&a[0] + 8B" not folded to &a[2]
> which might improve the issue.

I doubt this is the case; both &a[2] and "&a[0] + 8B" should produce
identical rtl (and anyway, there is nothing wrong with &a[0] + 8B,
so I guess the problem must be elsewhere).

I will check tomorrow.

Zdenek
Comment 7 Zdenek Dvorak 2004-09-21 11:49:39 UTC
This is caused by speculative prefetching.  The problem is in code like this:

(insn 14 12 15 1 (set (reg:SI 1 dx)
        (const_int 0 [0x0])) -1 (nil)
    (nil))

(insn 15 14 16 1 (set (reg:SI 0 ax)
        (mem/s:SI (reg/f:SI 62 [ ivtmp.5 ]) [2 a S4 A8])) -1 (nil)
    (nil))

(call_insn 16 15 17 1 (call (mem:QI (symbol_ref:SI ("foo") [flags 0x3]
<function_decl 0x40206ae0 foo>) [0 S1 A8])
        (const_int 0 [0x0])) -1 (nil)
    (expr_list:REG_EH_REGION (const_int 0 [0x0])
        (nil))
    (expr_list (use (reg:SI 0 ax))
        (expr_list (use (reg:SI 1 dx))
            (nil))))

Now we issue a profiling code for mem in insn 15.  This causes life range
of dx to be prolonged, and ICE follows.

safe_insert_insn_on_edge needs to be extended to handle this, somehow.
Comment 8 Andrew Pinski 2004-09-21 12:59:18 UTC
This is related to PR 17491 then.
Comment 9 Zdenek Dvorak 2004-09-21 20:38:44 UTC
Patch:

http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02116.html
Comment 10 Tim Savannah 2004-09-25 23:32:24 UTC
Patch fixes it, not yet submitted to cvs however.
Comment 11 Volker Reichelt 2004-10-16 13:29:12 UTC
Speculative prefetching is now disabled by default on mainline by
David Edelsohn's patch
http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg00928.html

Therefore, one has to add -fspeculative-prefetching to the command line
to trigger the bug on mainline.
Comment 12 Volker Reichelt 2004-10-28 09:28:35 UTC
Because of the patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01513.html
that adds "-funroll-loops" to "-fprofile-generate" the testcase from
comment #4 has to be compiled with
"-msse -O2 -fspeculative-prefetching -fprofile-generate -fno-unroll-loops"
to still trigger the bug. Alternatively one can increase the number of
iterations of the loop from 2 to 20.

The bug finally disappeared with Zdenek's patch
http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01561.html
which seems to address Andrew's suggestion from comment #5.

Zdenek, is this a real fix or is this just papering over the problem?
I.e. is your patch from comment #9 still needed or not?


Alas, the original testcase still segfaults with mainline. Here's a testcase:

==============================================================
int foo(int, int) __attribute__((pure));

void bar()
{
    int i;

    if (foo(0,0))
        for (i = 0; i < 2; i++)
            ;
}
==============================================================

Compile with "-O -march=pentium4 -fprofile-generate -fspeculative-prefetching
-funroll-loops"
to trigger the bug.

Phils's regression tester about this bug:
: Search converges between 2004-10-01-014001-trunk (#570) and
2004-10-01-161002-trunk (#571).
Comment 13 Volker Reichelt 2004-10-28 11:42:36 UTC
Zdenek, the failure in comment #12 appears with your patch
http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg00030.html
Comment 14 Zdenek Dvorak 2004-10-28 13:18:53 UTC
Subject: Re:  [4.0 Regression] internal compiler error: in spill_failure, at
reload1.c:1880

Hello,

> Because of the patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01513.html
> that adds "-funroll-loops" to "-fprofile-generate" the testcase from
> comment #4 has to be compiled with
> "-msse -O2 -fspeculative-prefetching -fprofile-generate -fno-unroll-loops"
> to still trigger the bug. Alternatively one can increase the number of
> iterations of the loop from 2 to 20.
> 
> The bug finally disappeared with Zdenek's patch
> http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01561.html
> which seems to address Andrew's suggestion from comment #5.
> 
> Zdenek, is this a real fix or is this just papering over the problem?

no, that patch cannot fix the problem; so it is just masked, and ...

> I.e. is your patch from comment #9 still needed or not?

... this patch is still needed.

Zdenek

> 
> Alas, the original testcase still segfaults with mainline. Here's a testcase:
> 
> ==============================================================
> int foo(int, int) __attribute__((pure));
> 
> void bar()
> {
>     int i;
> 
>     if (foo(0,0))
>         for (i = 0; i < 2; i++)
>             ;
> }
> ==============================================================
> 
> Compile with "-O -march=pentium4 -fprofile-generate -fspeculative-prefetching
> -funroll-loops"
> to trigger the bug.
> 
> Phils's regression tester about this bug:
> : Search converges between 2004-10-01-014001-trunk (#570) and
> 2004-10-01-161002-trunk (#571).
> 
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17428
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
Comment 15 Zdenek Dvorak 2004-11-04 07:06:23 UTC
Patch for the other problem:

http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00260.html
Comment 16 Andrew Pinski 2004-11-27 00:25:40 UTC
Even though this huge failure, it is no longer a regression as
-fspeculative-prefetching is not enabled 
wth -fprofile-generate/use but it still needs to be fixed but not necessarly
for 4.0.0.  Really someone 
should just approve Zdenek's fix for this.
Comment 17 CVS Commits 2005-02-14 11:38:03 UTC
Subject: Bug 17428

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rakdver@gcc.gnu.org	2005-02-14 11:37:53

Modified files:
	gcc            : ChangeLog value-prof.c cfgrtl.c 

Log message:
	PR target/17428
	* cfgrtl.c (safe_insert_insn_on_edge): Avoid extending life range of hard
	registers.
	* value-prof.c (insn_prefetch_values_to_profile): Only scan normal insns.
	
	* value-prof.c (rtl_find_values_to_profile): Do not look for values to
	profile in libcalls.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7467&r2=2.7468
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/value-prof.c.diff?cvsroot=gcc&r1=1.16&r2=1.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&r1=1.157&r2=1.158

Comment 18 Volker Reichelt 2005-02-15 12:56:25 UTC
Zdenek, are you going to add a testcase for the problem on mainline?
Is this a latent problem on other branches?
If not, can this PR be closed?
Comment 19 Volker Reichelt 2005-04-11 09:47:31 UTC
Zdenek,
the ICE with the testcase from comment #12 reappeared on mainline.
Could you please have a look?
Comment 20 Volker Reichelt 2005-04-11 10:32:53 UTC
The new failure (which is a segfault, btw) was caused by
http://gcc.gnu.org/ml/gcc-cvs/2005-03/msg01363.html
Comment 21 Zdenek Dvorak 2005-04-11 10:41:24 UTC
Subject: Re:  internal compiler error: in spill_failure, at reload1.c:1880
(-fspeculative-prefetching)

Hello,

> the ICE with the testcase from comment #12 reappeared on mainline.
> Could you please have a look?

it is because the patch you identified
(http://gcc.gnu.org/ml/gcc-cvs/2005-03/msg01363.html) reverted the
patch that fixed the problem
(http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/value-prof.c.diff?cvsroot=gcc&r1=1.16&r2=1.17).

Honza, could you please fix that?

Zdenek
Comment 22 Volker Reichelt 2005-06-02 16:08:39 UTC
Any news on this one, Honza?
Comment 23 Volker Reichelt 2005-07-29 09:41:20 UTC
The testcases from comment #4 and comment #12 were fixed on the 4.0 branch.
The problem persisted on mainline where -fspeculative-prefetching had
to be added. Since -fspeculative-prefetching was removed yesterday
(see http://gcc.gnu.org/ml/gcc-cvs/2005-07/msg01035.html )
the bug cannot be triggered on mainline anymore.

So closing as fixed.

Btw, the original testcase cannot be accessed anymore, so the testcases
from comment #4 and #12 are all we've got.