Bug 36680 - ICE in spill_failure, reload1.c:1995
Summary: ICE in spill_failure, reload1.c:1995
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, ra
Depends on:
Blocks:
 
Reported: 2008-06-30 17:54 UTC by Daniel Franke
Modified: 2012-09-02 08:12 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target:
Build:
Known to work: 4.5.3, 4.6.3, 4.7.1
Known to fail: 4.2.4, 4.3.3, 4.4.0
Last reconfirmed: 2009-01-03 11:32:14


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Franke 2008-06-30 17:54:16 UTC
The code snippet below compiles on FCFLAGS="-O1" and FCFLAGS="-O2", but gives an ICE on FCFLAGS="-O1 -fschedule-insns". The additional option is supposed to be part of -O2, according to [1]. 

The problem seems to be target-related as I could not reproduce it on i686-pc-linux-gnu.

Code is reduced, but probably not minimal yet. 

$> cat ice.f90
MODULE class_dummy_atom_kdtree_types
  TYPE dummy_atom_kdtree_data
    INTEGER :: dummy
  END TYPE

  TYPE :: dummy_atom_kdtree_node
    TYPE(dummy_atom_kdtree_node_private), POINTER :: p
  END TYPE

  TYPE :: dummy_atom_kdtree_node_private
    TYPE(dummy_atom_kdtree_data)                  :: data
  END TYPE

  TYPE :: dummy_atom_kdtree
    TYPE(dummy_atom_kdtree_node) :: root
  END TYPE
END MODULE

FUNCTION dummy_atom_kdtree_insert(this, item)
  USE class_dummy_atom_kdtree_types, ONLY: dummy_atom_kdtree, dummy_atom_kdtree_node, dummy_atom_kdtree_data

  TYPE(dummy_atom_kdtree), INTENT(inout)   :: this
  TYPE(dummy_atom_kdtree_data), INTENT(in) :: item

  TYPE(dummy_atom_kdtree_data)             :: dummy_atom_kdtree_insert

  TYPE(dummy_atom_kdtree_node) :: parent, current
  TYPE(dummy_atom_kdtree_node) :: node
  INTEGER :: cmp, level, discriminator

  parent        = dummy_atom_kdtree_node(null())
  current       = this%root
  level         = 1
  discriminator = 1

  DO WHILE (ASSOCIATED( current%p ))
    discriminator = MODULO(level-1, 3) + 1
    cmp = dummy_atom_kdtree_data_compare(item, current%p%data, discriminator)
    level   = level + 1
  END DO

  dummy_atom_kdtree_insert = item
END FUNCTION

$> gfortran-svn -O1 -fschedule-insns ice.f90
ice.f90: In function 'dummy_atom_kdtree_insert':
ice.f90:42: error: unable to find a register to spill in class 'AREG'
ice.f90:42: error: this is the insn:
(insn 19 31 20 4 ice.f90:37 (parallel [
            (set (reg:SI 37 r8 [69])
                (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (reg:SI 37 r8 [68]))
                            (zero_extend:DI (reg:SI 42 r13 [78])))
                        (const_int 32 [0x20]))))
            (clobber (scratch:SI))
            (clobber (reg:CC 17 flags))
        ]) 342 {*umulsi3_highpart_insn} (expr_list:REG_DEAD (reg:SI 37 r8 [68])
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))
ice.f90:42: internal compiler error: in spill_failure, at reload1.c:1995
Please submit a full bug report,

$> gfortran-svn -v
gcc version 4.4.0 20080629 (experimental) (GCC)

The same holds for 4.3.2.

[1] http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options
Comment 1 Andrew Pinski 2008-06-30 17:59:49 UTC
No -fschedule-insns is not included for x86 because of register pressure.
See PR 27001 also.  There are many others due to the RA being dumb.
Comment 2 Thomas Koenig 2009-01-03 11:32:14 UTC
Confirmed, goes back at least to 4.2 (so not a regression).
Comment 3 Uroš Bizjak 2009-09-17 11:55:36 UTC
Is this failure still triggered with recent mainline after http://gcc.gnu.org/ml/gcc-cvs/2009-09/msg00094.html ?
Comment 4 Uroš Bizjak 2012-09-01 21:24:09 UTC
Can someone please fix fortran in the testcase, so it will compile with gcc 4.8?
Comment 5 Dominique d'Humieres 2012-09-01 22:12:27 UTC
> Can someone please fix fortran in the testcase, so it will compile with gcc
> 4.8?

The mailer has split a line in two:

  USE class_dummy_atom_kdtree_types, ONLY: dummy_atom_kdtree,
dummy_atom_kdtree_node, dummy_atom_kdtree_data

You can unsplit them, or replace them with (adding a & at the end of the first line)

  USE class_dummy_atom_kdtree_types, ONLY: dummy_atom_kdtree, &
  dummy_atom_kdtree_node, dummy_atom_kdtree_data

I get the ICE with 4.4.6, but the code compiles with 4.5.3, 4.6.3, 4.7.1, and trunk and '-O1 -fschedule-insns'.
Comment 6 Uroš Bizjak 2012-09-01 22:21:05 UTC
(In reply to comment #5)

> I get the ICE with 4.4.6, but the code compiles with 4.5.3, 4.6.3, 4.7.1, and
> trunk and '-O1 -fschedule-insns'.

I propose we put the testcase in the testsuite (with -O1 -fschedule-insns for x86) and close the bug.

Dominique, can you perhaps prepare the test in a correct way for the testsuite?
Comment 7 Dominique d'Humieres 2012-09-01 22:47:21 UTC
> Dominique, can you perhaps prepare the test in a correct way for the testsuite?

I have tested a slightly reduced version

! { dg-do compile }
! { dg-options "-O1 -fschedule-insns" }
MODULE class_dummy_atom_kdtree_types
  TYPE dummy_atom_kdtree_data
    INTEGER :: dummy
  END TYPE

  TYPE :: dummy_atom_kdtree_node
    TYPE(dummy_atom_kdtree_node_private), POINTER :: p
  END TYPE

  TYPE :: dummy_atom_kdtree_node_private
    TYPE(dummy_atom_kdtree_data)                  :: data
  END TYPE

  TYPE :: dummy_atom_kdtree
    TYPE(dummy_atom_kdtree_node) :: root
  END TYPE
END MODULE

FUNCTION dummy_atom_kdtree_insert(this, item)
  USE class_dummy_atom_kdtree_types

  TYPE(dummy_atom_kdtree), INTENT(inout)   :: this
  TYPE(dummy_atom_kdtree_data), INTENT(in) :: item

  TYPE(dummy_atom_kdtree_node) :: parent, current
  INTEGER :: cmp, level, discriminator

  parent        = dummy_atom_kdtree_node(null())
  current       = this%root
  level         = 1
  discriminator = 1

  DO WHILE (ASSOCIATED( current%p ))
    discriminator = MODULO(level-1, 3) + 1
    cmp = dummy_atom_kdtree_data_compare(item, current%p%data, discriminator)
    level   = level + 1
  END DO

END FUNCTION

What is the magic to avoid the -O in "-O  -O1 -fschedule-insns"?

For the record the original test and the reduced one compiles on powerpc-apple-darwin9 also with 4.3.0 and 4.4.6.
Comment 8 Uroš Bizjak 2012-09-02 08:01:50 UTC
(In reply to comment #7)

> What is the magic to avoid the -O in "-O  -O1 -fschedule-insns"?

You can't.  This is how currently gfortran testsuite works.

The part that should eventually be fixed is in lib/gfortran.exp:

	# look if this is dg-do-run test, in which case
	# we cycle through the option list, otherwise we don't
	if [expr [search_for $test "dg-do run"]] {
	    set option_list $torture_with_loops
	} else {
	    set option_list [list { -O } ]
	}
Comment 9 uros 2012-09-02 08:10:26 UTC
Author: uros
Date: Sun Sep  2 08:10:21 2012
New Revision: 190855

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190855
Log:
	PR target/36680
	* gfortran.dg/pr36680.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/pr36680.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 10 Uroš Bizjak 2012-09-02 08:12:44 UTC
Closed as fixed in 4.8.0.