Bug 77901 - ICE in tree-sse-reassoc,c:2881
Summary: ICE in tree-sse-reassoc,c:2881
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-08 10:06 UTC by Bernd Edlinger
Modified: 2016-10-10 08:34 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-10-08 00:00:00


Attachments
gcc7-pr77901.patch (634 bytes, patch)
2016-10-08 16:12 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Edlinger 2016-10-08 10:06:49 UTC
build of gdb-7.11.1 with gcc Revision: 240867 fails with ICE
last week it was OK.

../../gdb-7.11.1/gdb/coffread.c: In function 'decode_type':
../../gdb-7.11.1/gdb/coffread.c:1816:1: internal compiler error: tree check: expected ssa_name, have bit_and_expr in optimize_range_tests_var_bound, at tree-ssa-reassoc.c:2881
 decode_type (struct coff_symbol *cs, unsigned int c_type,
 ^~~~~~~~~~~
0xe1d73c tree_check_failed(tree_node const*, char const*, int, char const*, ...)
	../../gcc-trunk/gcc/tree.c:9743
0xd371b1 tree_check(tree_node*, char const*, int, char const*, tree_code)
	../../gcc-trunk/gcc/tree.h:3031
0xd371b1 optimize_range_tests_var_bound
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:2881
0xd371b1 optimize_range_tests
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:3113
0xd38c7f reassociate_bb
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:5604
0xd38aad reassociate_bb
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:5723
0xd38aad reassociate_bb
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:5723
0xd3b3b9 do_reassoc
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:5837
0xd3b3b9 execute_reassoc
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:5924
0xd3b3b9 execute
	../../gcc-trunk/gcc/tree-ssa-reassoc.c:5963
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[2]: *** [coffread.o] Error 1
make[2]: Leaving directory `/home/ed/gnu/gdb-build/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/home/ed/gnu/gdb-build'
make: *** [all] Error 2
Comment 1 Bernd Edlinger 2016-10-08 10:28:27 UTC
this seems to fix it:

Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c	(revision 240867)
+++ gcc/tree-ssa-reassoc.c	(working copy)
@@ -2876,7 +2876,7 @@
       gimple *stmt;
       tree_code ccode;
       tree rhs1, rhs2;
-      if (ranges[i].exp)
+      if (ranges[i].exp && TREE_CODE (ranges[i].exp) == SSA_NAME)
 	{
 	  stmt = SSA_NAME_DEF_STMT (ranges[i].exp);
 	  if (!is_gimple_assign (stmt))
Comment 2 Bernd Edlinger 2016-10-08 14:35:59 UTC
reproducer:

cat min.c
union internal_auxent
{
 struct {
  union {
   long l;
  } x_tagndx;
 } x_sym;
};
struct coff_symbol
{
 int c_sclass;
};
int complaint ();
int decode_type (struct coff_symbol * cs, union internal_auxent * aux)
{
if (aux->x_sym.x_tagndx.l)
 if (cs->c_sclass != 10 && cs->c_sclass != 12 && aux->x_sym.x_tagndx.l >= 0)
   complaint ();
}
Comment 3 Jakub Jelinek 2016-10-08 16:12:54 UTC
Created attachment 39775 [details]
gcc7-pr77901.patch

Thanks for the report, but the #c1 patch is incorrect, we don't want to handle .exp non-NULL other than SSA_NAME as if it is a GIMPLE_COND comparison at the end of bb, we just want to ignore that instead.
Comment 4 Bernd Edlinger 2016-10-08 16:24:20 UTC
ok, thanks.
Comment 5 Jakub Jelinek 2016-10-09 11:19:26 UTC
Author: jakub
Date: Sun Oct  9 11:18:53 2016
New Revision: 240899

URL: https://gcc.gnu.org/viewcvs?rev=240899&root=gcc&view=rev
Log:
	PR tree-optimization/77901
	* tree-ssa-reassoc.c (optimize_range_tests_var_bound): Only optimize
	if ranges[i].exp is SSA_NAME when looking for >= and only when
	ranges[i].exp is NULL or SSA_NAME when looking for the other
	comparison.

	* gcc.c-torture/compile/pr77901.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr77901.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-reassoc.c
Comment 6 Jakub Jelinek 2016-10-10 08:34:10 UTC
Fixed.