Bug 21293 - [4.0 Regression] ICE in set_value_handle
Summary: [4.0 Regression] ICE in set_value_handle
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, patch
: 21497 (view as bug list)
Depends on:
Blocks: 21331
  Show dependency treegraph
 
Reported: 2005-04-29 23:13 UTC by Dale Johannesen
Modified: 2005-05-21 16:58 UTC (History)
4 users (show)

See Also:
Host: powerpc-apple-darwin8.0.0
Target: powerpc-apple-darwin8.0.0
Build: powerpc-apple-darwin8.0.0
Known to work: 3.4.0 4.1.0
Known to fail: 4.0.0
Last reconfirmed: 2005-04-30 01:29:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Johannesen 2005-04-29 23:13:21 UTC
The following crashes at compile time with -O2, on a local compiler built from 4.0 branch sources:
foo3.c: In function 'gciprt_':
foo3.c:8: internal compiler error: in set_value_handle, at tree-vn.c:179
(This has been cut down from a large original which did not have all those uninitialized variables.)

struct {
int k_;
} detwfn_;
struct {
double x_[1];
} fmcom_;
void gciprt_(int *iw_)
{
int Tmp8, ibcon_, iwrk_, ibo_, jstsym_, lcivec_, iacon_, igmul_;
int i_, nsym_, ipica_, ipicb_;
ibo_ = iwrk_ + 43;
Tmp8 = detwfn_.k_;
for(i_ = 1;i_ <= Tmp8;i_++) {
  gcisym_(iw_,&fmcom_.x_[lcivec_ + -1],&fmcom_.x_[ipica_ + -1],&fmcom_.x_[ipicb_ + -1],
  &fmcom_.x_[iacon_ + -1],&fmcom_.x_[ibcon_ + -1],&fmcom_.x_[igmul_ + -1],&nsym_,
  &fmcom_.x_[iwrk_ + -1],&fmcom_.x_[ibo_ + -1],&jstsym_);
}
return ;
}
Comment 1 Daniel Berlin 2005-04-30 00:17:33 UTC
Fold turns

 D.1157 = &fmcom_D.1134.x_D.1132[0] + -8B;
into

D.1157 = &fmcom_D.1134.x_D.1132[-000000001];

which seems very wrong (we eventually crap out on the overflowed constant)
Comment 2 Andrew Pinski 2005-04-30 00:46:21 UTC
(In reply to comment #1)
> Fold turns
> 
>  D.1157 = &fmcom_D.1134.x_D.1132[0] + -8B;
> into
> 
> D.1157 = &fmcom_D.1134.x_D.1132[-000000001];
> 
> which seems very wrong (we eventually crap out on the overflowed constant)

Now if this was not an overflowed constant, it would be valid.

Comment 3 Andrew Pinski 2005-04-30 01:10:29 UTC
This works on the mainline but fails on the 4.0.0 branch.
I think this was fixed on the mainline by:
2005-03-14  Zdenek Dvorak  <dvorakz@suse.cz>

        * tree-cfg.c (find_taken_edge_cond_expr): Use zero_p instead of
        integer_zerop.
        * tree-gimple.c (is_gimple_min_invariant): Consider overflowed
        constants invariant.
Comment 4 Andrew Pinski 2005-04-30 01:17:33 UTC
I just checked and a back porting of that patch fixes the ICE.

I might do the bootstrap/testing if I get some time tomorrow or later this week.
Comment 5 Andrew Pinski 2005-04-30 01:29:38 UTC
Reduced even further:
struct {
double x[1];
} g;
void k( double *, double*);
void h(int Tmp8)
{
  int i;
  for(i = 1;i <= Tmp8;i++)
    k(&g.x[ + -1],&g.x[ Tmp8 + -1]);
}
Comment 6 Dale Johannesen 2005-04-30 01:56:42 UTC
Yes, I figured out that allowing overflowed constants in is_gimple_min_invariant would fix it.  But
that doesn't seem like it should be necessary for correctness.  Zdenek changed it to improve
optimization, not because it broke things.
Comment 7 Daniel Berlin 2005-04-30 01:58:31 UTC
This is also what i figured was the patch that fixed it
However, it *is* necessary for correctness because we need to consider constants
to be invariant, or else set_value_handle and friends will break.

We have nothing in a constant to hang a value handle off :)
Comment 8 Dale Johannesen 2005-04-30 02:45:36 UTC
Certainly.  Presumably the expectation was that overflowed constants would not get here.
But I confess I don't see why not.
Comment 9 Daniel Berlin 2005-04-30 03:06:18 UTC
because they are supposed to also be constant, because even though overflowed,
they do not change, ever.  :)

constants are constants are constants are constants.  If it's not a constant, it
shouldn't be a _CST node.
In addition, all _CST nodes should be is_gimple_min_invariant, because they are
a subset of the invariants.

We don't give CST nodes value handles, because their value is always themselves.

This one was not until Zdenek's change. That is a bug, and he fixed it.
The verifier catches it because it checks to make sure that everything it
doesn't give a value handle to is a min_invariant  (as they should be :P)

Comment 10 GCC Commits 2005-05-02 17:15:26 UTC
Subject: Bug 21293

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	apple-local-200502-branch
Changes by:	dalej@gcc.gnu.org	2005-05-02 17:15:15

Modified files:
	gcc            : ChangeLog.apple-ppc tree-cfg.c tree-gimple.c 
	gcc/fortran    : trans-intrinsic.c 

Log message:
	2005-05-02  Dale Johannesen  <dalej@apple.com>
	
	Radar 4102133  (PR 21293, Zdenek's patch)
	* tree-cfg.c (find_taken_edge_cond_expr): Use zero_p instead of
	integer_zerop.
	* tree-gimple.c (is_gimple_min_invariant): Consider overflowed
	constants invariant.
	* fortran/trans-intrinsic.c (gfc_conv_intrinsic_ishft): Convert
	the argument of the shift to the unsigned type.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=1.1.4.57&r2=1.1.4.58
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-cfg.c.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=2.149.4.2&r2=2.149.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-gimple.c.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=2.35&r2=2.35.8.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-intrinsic.c.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=1.43.6.1&r2=1.43.6.2

Comment 11 Andrew Pinski 2005-05-10 16:27:32 UTC
*** Bug 21497 has been marked as a duplicate of this bug. ***
Comment 12 Andrew Pinski 2005-05-16 00:29:13 UTC
Mine, patch posted.
Comment 13 GCC Commits 2005-05-21 16:57:31 UTC
Subject: Bug 21293

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-05-21 16:57:25

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: pr21293.c 
	gcc/testsuite/gcc.c-torture/execute: pr21331.c 

Log message:
	2004-05-21  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/21331
	PR tree-opt/21293
	* gcc.c-torture/compile/pr21293.c: New test.
	* gcc.c-torture/execute/pr21331.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5504&r2=1.5505
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/pr21293.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr21331.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 14 Andrew Pinski 2005-05-21 16:58:20 UTC
Fixed.
Comment 15 GCC Commits 2005-05-21 16:59:22 UTC
Subject: Bug 21293

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	pinskia@gcc.gnu.org	2005-05-21 16:58:46

Modified files:
	gcc            : ChangeLog tree-cfg.c tree-gimple.c 
	gcc/fortran    : ChangeLog trans-intrinsic.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: pr21293.c 
	gcc/testsuite/gcc.c-torture/execute: pr21331.c 

Log message:
	2005-05-21  Andrew Pinski
	
	Backport from the mainline:
	2005-03-14  Zdenek Dvorak  <dvorakz@suse.cz>
	* fortran/trans-intrinsic.c (gfc_conv_intrinsic_ishft): Convert
	the argument of the shift to the unsigned type.
	
	2005-05-21  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/21331
	PR tree-opt/21293
	Backport from the mainline:
	2005-03-14  Zdenek Dvorak  <dvorakz@suse.cz>
	* tree-cfg.c (find_taken_edge_cond_expr): Use zero_p instead of
	integer_zerop.
	* tree-gimple.c (is_gimple_min_invariant): Consider overflowed
	constants invariant.
	2004-05-21  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/21331
	PR tree-opt/21293
	* gcc.c-torture/compile/pr21293.c: New test.
	* gcc.c-torture/execute/pr21331.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.256&r2=2.7592.2.257
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-cfg.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.151&r2=2.151.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-gimple.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.35&r2=2.35.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.53&r2=1.335.2.54
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-intrinsic.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.43.10.4&r2=1.43.10.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.191&r2=1.5084.2.192
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/pr21293.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr21331.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1