Bug 34127 - [4.3 Regression] ICE: tree-ssa-operands.c:1688
Summary: [4.3 Regression] ICE: tree-ssa-operands.c:1688
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
: 34122 (view as bug list)
Depends on:
Blocks: 33604 34113
  Show dependency treegraph
 
Reported: 2007-11-16 21:10 UTC by Ralf W. Grosse-Kunstleve
Modified: 2007-11-19 04:04 UTC (History)
5 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: 2007-11-18 13:06:48


Attachments
reproducer (1.88 KB, text/plain)
2007-11-16 21:11 UTC, Ralf W. Grosse-Kunstleve
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf W. Grosse-Kunstleve 2007-11-16 21:10:21 UTC
Platform:
  Fedora release 7 (Moonshine)
  Linux idle.lbl.gov 2.6.22.9-91.fc7 #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64
x86_64 x86_64 GNU/Linux

% g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /net/rosie/scratch2/rwgk/gcc_trunk/configure --prefix=/net/cci-filer1/vol1/tmp/rwgk/gcc_trunk_130232_x86_64_fc7 --enable-languages=c,c++,fortran --with-mpfr=/usr
Thread model: posix
gcc version 4.3.0 20071116 (experimental) (GCC)

I'll attach a stand-alone reproducer.

It works with -O0 but not -O1 or higher:

% gcc -c -fno-strict-aliasing -O1 -Wall ice_ssa.c
ice_ssa.c: In function 's_init':
ice_ssa.c:281: internal compiler error: in get_addr_dereference_operands, at tree-ssa-operands.c:1688
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The reproducer is derived from: Python-2.5.1/Modules/_struct.c
It is still quite big (297 lines) but has no external
dependencies. I've spend a significant amount of time stripping
it down starting from ca. 6000 lines of pre-processed code. I hope
you can do the rest much faster than I could.

Ralf
Comment 1 Ralf W. Grosse-Kunstleve 2007-11-16 21:11:10 UTC
Created attachment 14568 [details]
reproducer
Comment 2 Richard Biener 2007-11-17 12:40:01 UTC
Works for me, this is a dup of PR34113.

*** This bug has been marked as a duplicate of 34113 ***
Comment 3 Ralf W. Grosse-Kunstleve 2007-11-18 02:54:05 UTC
(In reply to comment #2)
> Works for me, this is a dup of PR34113.
> 
> *** This bug has been marked as a duplicate of 34113 ***
> 

This is not the case. My original bug report was based on svn revision
130232, which includes the fix for PR34113 (fixed with svn revision
130223).

I tried again today from scratch with svn revision 130261 (this time
under Fedora 5 because the other machine crashed):

% gcc -fPIC -c -O3 ice_ssa_34127.c
ice_ssa_34127.c: In function 'prepare_s':
ice_ssa_34127.c:297: internal compiler error: in get_addr_dereference_operands, at tree-ssa-operands.c:1688
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 4 Richard Biener 2007-11-18 12:50:24 UTC
Whoops, sorry.  Reduced testcase:

static void 
whichtable(char **pfmt)
{
  --*pfmt;
}
void prepare_s(const char *fmt)
{
  whichtable((char **)&fmt);
}

./cc1 -quiet -O t2.i
t2.i: In function 'prepare_s':
t2.i:7: internal compiler error: in get_addr_dereference_operands, at tree-ssa-operands.c:1688
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 5 Richard Biener 2007-11-18 13:53:01 UTC
Hm, this is an unlucky case because of the way fold_stmt works.  What we have is
(even more simplified):

void prepare_s(const char *fmt)
{
  char ** f = (char **)&fmt;
  *f = 0;
}

where it is not hard to see that for the store we can substitute

  fmt = 0;

as a char * rhs can be trivially converted to a const char * lhs.

Now what happens is that forwprop decides for this reason that a
propagation of (char **)&fmt is worthwhile and asks fold_stmt_in_place
to fold

  *(char **)&fmt = 0;

now the path goes through maybe_fold_stmt_indirect which only strips
same-type conversions (STRIP_TYPE_NOPS) and so fails to dispatch to
maybe_fold_offset_to_reference.  Now, if we strip the conversion in
forwprop already then in turn maybe_fold_offset_to_reference fails to
do the conversion because it (even while it would strip all conversions)
asks if the conversion from const char * to char * is useless (which
it is not) and refuses to do the trivial folding.
Comment 6 Richard Biener 2007-11-18 15:50:08 UTC
Subject: Bug 34127

Author: rguenth
Date: Sun Nov 18 15:49:57 2007
New Revision: 130269

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130269
Log:
2007-11-18  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/34127
	* tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars):
	Make code match up the comments, require compatibility of the
	pointed-to types.

	* gcc.c-torture/compile/pr34127.c: New testcase.

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

Comment 7 Richard Biener 2007-11-18 15:50:41 UTC
Fixed.
Comment 8 Andrew Pinski 2007-11-19 04:04:39 UTC
*** Bug 34122 has been marked as a duplicate of this bug. ***