Bug 27373 - [4.2 Regression] ICE: add_virtual_operand with pointers to arrays
Summary: [4.2 Regression] ICE: add_virtual_operand with pointers to arrays
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 27085 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-01 18:10 UTC by Joost VandeVondele
Modified: 2006-05-17 16:45 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-14 09:00:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2006-05-01 18:10:31 UTC
gcc version 4.2.0 20060501 (experimental)

> gfortran -c -O2 bug.f90
bug.f90: In function âreset_to_next_rng_substreamâ:
bug.f90:11: internal compiler error: in add_virtual_operand, at tree-ssa-operands.c:1284

for :

> cat bug.f90
MODULE parallel_rng_types
  INTEGER, PARAMETER :: dp=KIND(0.0D0)
  TYPE rng_stream_type
    REAL(KIND=dp), DIMENSION(3,2) :: bg,cg,ig
    LOGICAL                       :: antithetic,extended_precision
  END TYPE rng_stream_type
  TYPE cp_error_type
    INTEGER :: dum
  END TYPE
CONTAINS
  SUBROUTINE reset_to_next_rng_substream(rng_stream,error)
    TYPE(rng_stream_type), POINTER           :: rng_stream
    LOGICAL                                  :: failure
    REAL(KIND=dp), DIMENSION(3, 2)           :: u
    CALL cp_assert(ASSOCIATED(rng_stream),2,routineP,error,failure)
    IF (.NOT.failure) THEN
      rng_stream%bg = u
      rng_stream%cg = u
    END IF
  END SUBROUTINE reset_to_next_rng_substream
END MODULE
Comment 1 Andrew Pinski 2006-05-02 07:22:34 UTC
Confirmed, not fixed by the patch which fixes PR 26626.
Here is a reduced Fortran testcase:
MODULE parallel_rng_types
  INTEGER, PARAMETER :: dp=KIND(0.0D0)
  TYPE rng_stream_type
    REAL(KIND=dp), DIMENSION(1) :: bg,cg
    LOGICAL                       :: antithetic
  END TYPE
CONTAINS
  SUBROUTINE reset_to_next_rng_substream(rng_stream,error)
    TYPE(rng_stream_type), POINTER           :: rng_stream
    LOGICAL                                  :: failure
    CALL cp_assert(ASSOCIATED(rng_stream),routineP,error,failure)
    IF (.NOT.failure) THEN
      rng_stream%bg = u
      rng_stream%cg = u
    END IF
  END SUBROUTINE reset_to_next_rng_substream
END MODULE

-----
I might get a reduced C one soon or not.
Comment 2 Andrew Pinski 2006-05-02 07:40:35 UTC
And here is the C example (so this does not become not release blocking):
typedef struct atype
{
    float bg[1], cg[1];
    _Bool ant;
}atype;


void cp_assert(_Bool*, float*, int*, _Bool*);

void f(atype **rng_stream, int *error, float u)
{
    _Bool t = *rng_stream != 0;
    float routinep;
    _Bool failure;
    cp_assert ( &t, &routinep, error, &failure);
    if (failure == 0)
    {
        typedef float ty[1];
	ty *tt = &((*rng_stream)->bg);
	int i = 1;
	
	do 
	{
	    (*tt)[i - 1] = u;
	    i ++;
	}while (i > 1);
	{
	    ty *tt = &(*rng_stream)->cg;
	    int i = 1;
	    
	    do 
	    {
		(*tt)[i - 1] = u;
		i ++;
	    }while (i > 1);
	}
    }    
}
Comment 3 Richard Biener 2006-05-02 08:51:53 UTC
The patch for PR26626 doesn't fix this either.
Comment 4 Richard Biener 2006-05-02 08:56:26 UTC
ICEing in the propagator engine during copyprop:

Substituing values and folding statements

Folded statement: tt_19 = &D.1547_18->cg;
            into: tt_19 = &D.1547_12->cg;

*kaboom*

but same usual place:

#1  0x081881af in add_virtual_operand (var=0xb7d8e410, s_ann=0xb7e1a7ec, 
    flags=1, full_ref=0xb7e1a208, offset=32, size=32, for_clobber=0 '\0')
    at /space/rguenther/src/svn/trunk/gcc/tree-ssa-operands.c:1284
1284                    gcc_assert (SMT_USED_ALONE (var));

(gdb) call debug_generic_expr(stmt)
#   SMT.8D.1563_39 = V_MAY_DEF <SMT.8D.1563_14>;
D.1547_12->cgD.1522[D.1552_21] = uD.1532_16
Comment 5 Daniel Berlin 2006-05-02 12:19:32 UTC
Subject: Re:  [4.2 Regression] ICE:
	add_virtual_operand with pointers to arrays

On Tue, 2006-05-02 at 08:56 +0000, rguenth at gcc dot gnu dot org wrote:
> 
> ------- Comment #4 from rguenth at gcc dot gnu dot org  2006-05-02 08:56 -------
> ICEing in the propagator engine during copyprop:
> 
> Substituing values and folding statements
> 
> Folded statement: tt_19 = &D.1547_18->cg;
>             into: tt_19 = &D.1547_12->cg;
> 
> *kaboom*
> 
> but same usual place:
> 
> #1  0x081881af in add_virtual_operand (var=0xb7d8e410, s_ann=0xb7e1a7ec, 
>     flags=1, full_ref=0xb7e1a208, offset=32, size=32, for_clobber=0 '\0')
>     at /space/rguenther/src/svn/trunk/gcc/tree-ssa-operands.c:1284
> 1284                    gcc_assert (SMT_USED_ALONE (var));
> 
> (gdb) call debug_generic_expr(stmt)
> #   SMT.8D.1563_39 = V_MAY_DEF <SMT.8D.1563_14>;
> D.1547_12->cgD.1522[D.1552_21] = uD.1532_16

This is a different bug, in fact.
Those two (D.1547_18 and D.1547_12) should have had the exact same SMT
base, AFAICT, and thus, should have had the same result.

What do the alias dumps look like after the patch from 26626?



Comment 6 Francois-Xavier Coudert 2006-05-14 09:00:20 UTC
Any progress on this one? It's blocking a few widely-used Fortran codes from compiling (and being used and benchmarked) with mainline gfortran.
Comment 7 Daniel Berlin 2006-05-14 19:10:19 UTC
We aren't marking smt usage for updating in forwprop, but we need to, because forwprop is propagating and address and destroying the smt info.
Comment 8 Daniel Berlin 2006-05-17 01:16:15 UTC
Subject: Bug 27373

Author: dberlin
Date: Wed May 17 01:16:08 2006
New Revision: 113840

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113840
Log:
2006-05-16  Daniel Berlin <dberlin@dberlin.org>
	
	Fix PR tree-optimization/27373
	* tree-ssa-forwprop.c: (forward_propagate_addr_expr_1): Add argument.
	 (forward_propagate_addr_expr): Update call.


Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr27373.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-forwprop.c

Comment 9 Daniel Berlin 2006-05-17 12:07:55 UTC
Fixed
Comment 10 Andrew Pinski 2006-05-17 16:45:06 UTC
*** Bug 27085 has been marked as a duplicate of this bug. ***