Bug 38250 - ICE with -O2 -ftree-loop-distribution
Summary: ICE with -O2 -ftree-loop-distribution
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 36116 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-24 16:28 UTC by tomby
Modified: 2008-12-29 03:22 UTC (History)
3 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc ICEs on this file (244 bytes, text/plain)
2008-11-24 16:31 UTC, tomby
Details
This patch fixes problems (647 bytes, patch)
2008-11-24 16:42 UTC, tomby
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tomby 2008-11-24 16:28:54 UTC
GCC ICEs on folowing code with options -O2 -ftree-loop-distribution

typedef long unsigned int size_t;
typedef struct   {
      long dat[2];
} gsl_complex_long_double;
typedef struct {
    size_t size;
    size_t stride;
    long *data;
} gsl_vector_complex_long_double;
void gsl_vector_complex_long_double_set_zero (gsl_vector_complex_long_double * v) 
{
    long * const data = v->data;
    const size_t n = v->size;
    const size_t stride = v->stride;
    const gsl_complex_long_double zero = { { 0,0} } ;
    size_t i;
    for (i = 0; i < n; i++)     
        *(gsl_complex_long_double *) (data + 2 * i * stride) = zero;
}

as

prx.c: In function ‘gsl_vector_complex_long_double_set_zero’:
prx.c:10: internal compiler error: in fold_binary, at fold-const.c:9308


Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/abuild/tbily/install/ --enable-checks --enable-bootstrap --disable-multilib
Thread model: posix
gcc version 4.4.0 20081118 (experimental) (GCC)
Comment 1 tomby 2008-11-24 16:31:08 UTC
Created attachment 16758 [details]
gcc ICEs on this file
Comment 2 tomby 2008-11-24 16:39:26 UTC
In tree-loop-distribution.c (generate_memset_zero) can be DR_STEP(dr) NULL. But it is passed into fold_build2 that expect two non null expressions. 

If program flow goes to end: due to goto then temporary variables created during force_gimple_operand are added to referenced vars. But this variables have not def bb. So later checks fails.
Comment 3 tomby 2008-11-24 16:42:56 UTC
Created attachment 16760 [details]
This patch fixes problems
Comment 4 sebpop@gmail.com 2008-11-24 17:27:05 UTC
Subject: Re:  ICE with -O2 -ftree-loop-distribution

The patch looks good.  Please test and ask for approval to
commit to trunk on gcc-patches@.

Thanks,
Sebastian
Comment 5 tomby 2008-12-03 13:36:40 UTC
Subject: Bug 38250

Author: tomby
Date: Wed Dec  3 13:35:13 2008
New Revision: 142394

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142394
Log:
        PR middle-end/38250
        * tree-loop-distribution.c (build_size_arg): New function.
        (generate_memset_zero): Checks if DR_STEP(de) is NULL.
        Reorganized generating of stmts.
        * testsuite/gcc.dg/tree-ssa/pr38250.c: New file.
        * tree-data-ref.c (dr_analyze_innermost): Returns bool.
        Indicate if analysis succeed.
        * tree-data-ref.h (dr_analyze_innermost): Returns bool.
        * tree-predcom.c (valid_initializer_p, find_looparound_phi):
        Uses new definition of dr_analyze_innermost.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-data-ref.c
    trunk/gcc/tree-data-ref.h
    trunk/gcc/tree-loop-distribution.c
    trunk/gcc/tree-predcom.c

Comment 6 Sebastian Pop 2008-12-03 15:38:22 UTC
Fixed.
Comment 7 Volker Reichelt 2008-12-29 03:22:04 UTC
*** Bug 36116 has been marked as a duplicate of this bug. ***