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 ; }
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)
(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.
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.
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.
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]); }
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.
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 :)
Certainly. Presumably the expectation was that overflowed constants would not get here. But I confess I don't see why not.
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)
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
*** Bug 21497 has been marked as a duplicate of this bug. ***
Mine, patch posted.
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
Fixed.
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