Bug 33449 - [4.3 regression] ICE for fortran code with -O2 -ftree-vectorize
Summary: [4.3 regression] ICE for fortran code with -O2 -ftree-vectorize
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-09-16 18:17 UTC by David Binderman
Modified: 2007-09-17 10:42 UTC (History)
3 users (show)

See Also:
Host: x86_64-linux
Target: x86_64-linux
Build: x86_64-linux
Known to work: 4.2.2
Known to fail: 4.3.0
Last reconfirmed: 2007-09-17 08:39:44


Attachments
fortran source code (7.87 KB, text/plain)
2007-09-16 18:18 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2007-09-16 18:17:54 UTC
I just tried to compile lapack version 3.1.1
with the GNU Fortran compiler version 4.3 snapshot 20070914.

The compiler said

/home/dcb/gcc/20070914/results/bin/gfortran -g -O3 -Wall -ftree-vectorize -c dlarre.f -o dlarre.o
dlarre.f: In function 'dlarre':
dlarre.f:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Here is some help from valgrind

==32315== Invalid read of size 4
==32315==    at 0xAB06EA: vect_get_vec_defs_for_stmt_copy (tree.h:210)
==32315==    by 0xAB3CC5: vectorizable_operation (tree-vect-transform.c:3987)
==32315==    by 0xAC058B: vect_transform_stmt (tree-vect-transform.c:6095)
==32315==    by 0xAC1707: vect_transform_loop (tree-vect-transform.c:7334)
==32315==    by 0x80766B: vectorize_loops (tree-vectorizer.c:2507)
==32315==    by 0x64BCC8: execute_one_pass (passes.c:1115)
==32315==    by 0x64BE9F: execute_pass_list (passes.c:1168)
==32315==    by 0x64BEB4: execute_pass_list (passes.c:1169)
==32315==    by 0x64BEB4: execute_pass_list (passes.c:1169)
==32315==    by 0x72480F: tree_rest_of_compilation (tree-optimize.c:404)
==32315==    by 0x893DD3: cgraph_expand_function (cgraphunit.c:1070)
==32315==    by 0x896024: cgraph_optimize (cgraphunit.c:1139)
==32315==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
dlarre.f: In function 'dlarre':
dlarre.f:1: internal compiler error: Segmentation fault

Source attached. Flags -O2 -ftree-vectorize required.
Comment 1 David Binderman 2007-09-16 18:18:41 UTC
Created attachment 14214 [details]
fortran source code
Comment 2 Jack Howarth 2007-09-16 18:30:29 UTC
I'm not seeing this problem on powerpc-apple-darwin9. I am using a svn pull from gcc trunk that has the ICE fixes Dorit added in...

r128514 | dorit | 2007-09-15 14:24:23 -0400 (Sat, 15 Sep 2007) | 7 lines

        * tree-vect-transform.c (vect_get_vec_defs_for_stmt_copy): check if
        the VEC is not NULL.
        (vectorizable_type_demotion, vectorizable_type_promotion): Check that
        get_vectype_for_scalar_type succeeded.
        (vectorizable_conversion): Likewise.

You might want to try again with the current gcc trunk.
Comment 3 Francois-Xavier Coudert 2007-09-17 08:39:44 UTC
I can reproduce that on x86_64-linux with trunk rev. 128442. Severity set to critical, as this is LAPACK.

Program received signal SIGSEGV, Segmentation fault.
vect_get_vec_defs_for_stmt_copy (dt=0x7fff713d44c0, 
    vec_oprnds0=0x7fff713d44b8, vec_oprnds1=0x7fff713d44b0)
    at ../../../trunk/gcc/tree.h:210
210     DEF_VEC_P(tree);
(gdb) bt
#0  vect_get_vec_defs_for_stmt_copy (dt=0x7fff713d44c0, 
    vec_oprnds0=0x7fff713d44b8, vec_oprnds1=0x7fff713d44b0)
    at ../../../trunk/gcc/tree.h:210
#1  0x0000000000aacca6 in vectorizable_operation (stmt=0x2ac339ca5600, 
    bsi=0x7fff713d4660, vec_stmt=0x7fff713d4528, slp_node=0x0)
    at ../../../trunk/gcc/tree-vect-transform.c:3987
#2  0x0000000000ab95d4 in vect_transform_stmt (stmt=0x2ac339ca5600, 
    bsi=0x7fff713d4660, strided_store=0x7fff713d46cf "", slp_node=0x0)
    at ../../../trunk/gcc/tree-vect-transform.c:6095
#3  0x0000000000aba733 in vect_transform_loop (loop_vinfo=0x1091460)
    at ../../../trunk/gcc/tree-vect-transform.c:7334
#4  0x000000000080c28e in vectorize_loops ()
    at ../../../trunk/gcc/tree-vectorizer.c:2507
#5  0x000000000064e261 in execute_one_pass (pass=0xe22180)
    at ../../../trunk/gcc/passes.c:1115
#6  0x000000000064e440 in execute_pass_list (pass=0xe22180)
    at ../../../trunk/gcc/passes.c:1168
#7  0x000000000064e455 in execute_pass_list (pass=0xe21fa0)
    at ../../../trunk/gcc/passes.c:1169
#8  0x000000000064e455 in execute_pass_list (pass=0xe213a0)
    at ../../../trunk/gcc/passes.c:1169
#9  0x00000000007286e8 in tree_rest_of_compilation (fndecl=0x2ac339c14340)
    at ../../../trunk/gcc/tree-optimize.c:404


Reduced testcase is:

$ cat foo.f
      SUBROUTINE DLARRE (W, IBLOCK, WORK)
      INTEGER            M, I
      INTEGER            IBLOCK(*)
      DOUBLE PRECISION   W(*), WORK(*)
      DO JBLK = 1, 10
         DO I = 1, 10
           M = M + 1
           W(M) = -WORK(I)
           IBLOCK(M) = 0
         END DO
      END DO
      END
$ gfortran -O2 -ftree-vectorize foo.f
foo.f: In function ‘dlarre’:
foo.f:1: internal compiler error: Segmentation fault
Comment 4 Ira Rosen 2007-09-17 08:59:05 UTC
(In reply to comment #3)
> I can reproduce that on x86_64-linux with trunk rev. 128442. 

Dorit's fix is revision 128514, so it is not supposed to work on 128442...
Anyway, I am trying to reproduce this ICE on x86_64-linux now, with the current trunk (128538).

Ira
Comment 5 Ira Rosen 2007-09-17 09:54:17 UTC
(In reply to comment #4)
> Anyway, I am trying to reproduce this ICE on x86_64-linux now, with the current
> trunk (128538).

It doesn't ICE for me. (The loop gets vectorized).

Ira
Comment 6 Francois-Xavier Coudert 2007-09-17 10:42:47 UTC
Subject: Bug 33449

Author: fxcoudert
Date: Mon Sep 17 10:42:29 2007
New Revision: 128543

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128543
Log:
	PR middle-end/33449
	* gfortran.dg/pr33449.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr33449.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 7 Francois-Xavier Coudert 2007-09-17 10:42:57 UTC
Closing the bug, after adding a reduced testcase to the testsuite.