Bug 63941 - [5 Regression] ICE on valid code at -O3 and above on x86_64-linux-gnu
Summary: [5 Regression] ICE on valid code at -O3 and above on x86_64-linux-gnu
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P1 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-18 18:24 UTC by Zhendong Su
Modified: 2014-12-01 12:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-11-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2014-11-18 18:24:31 UTC
The following code causes an ICE when compiled with the current gcc trunk at -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It is a regression from 4.9.x.

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 5.0.0 20141117 (experimental) [trunk revision 217671] (GCC) 

$ gcc-trunk -O2 -c small.c
$ gcc-4.9 -O3 -c small.c
$ 
$ gcc-trunk -O3 -c small.c
small.c: In function ‘fn1’:
small.c:4:1: internal compiler error: in add_to_predicate_list, at tree-if-conv.c:438
 fn1 ()
 ^
0xb11044 add_to_predicate_list
	../../gcc-trunk/gcc/tree-if-conv.c:438
0xb11044 add_to_dst_predicate_list
	../../gcc-trunk/gcc/tree-if-conv.c:488
0xb11564 predicate_bbs
	../../gcc-trunk/gcc/tree-if-conv.c:1155
0xb11c7a combine_blocks
	../../gcc-trunk/gcc/tree-if-conv.c:2005
0xb13c06 tree_if_conversion
	../../gcc-trunk/gcc/tree-if-conv.c:2162
0xb13c06 execute
	../../gcc-trunk/gcc/tree-if-conv.c:2240
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.
$ 


-------------------------------


int a, b, c, d[1], e, f, g, h;

void
fn1 ()
{
  char i = 0;
  for (b = 0; b >= 0;)
    for (b = 0; b < 2; b++)
      {
	d[f] && (e = 0);
	h = 1 & a - i ? 0 : a;
	c = i = h;
	char j = c;
	int k = 0;
	g = j || j > k;
	d[0] = 0;
      }
}
Comment 1 H.J. Lu 2014-11-18 22:26:01 UTC
It was caused by r217277.
Comment 2 Yuri Rumyantsev 2014-11-28 15:35:34 UTC
My patch is responsible for ICE - I did not assume that before if-convert phase cfg may contain redundant degenerative conditional branches:

    <bb 4>:
...
    _14 = d[pretmp_51];
    if (_14 != 0)
      goto <bb 6>;
    else
      goto <bb 5>;
 
  }
  bb_5 (preds = {bb_4 }, succs = {bb_6 })
  {
    <bb 5>:
 
  }
  bb_6 (preds = {bb_5 bb_4 }, succs = {bb_10 bb_7 })

I deleted wrong assert and slightly changed code to set up predicate for join bb conditionally. With this fix test is compiled successfully.

The patch was sent to GCC community for review.
Comment 3 Ilya Enkovich 2014-12-01 12:19:59 UTC
Author: ienkovich
Date: Mon Dec  1 12:19:28 2014
New Revision: 218206

URL: https://gcc.gnu.org/viewcvs?rev=218206&root=gcc&view=rev
Log:
gcc/

	PR tree-optimization/63941
	* tree-if-conv.c (add_to_predicate_list): Delete wrong assertion that
	DOM_BB has non-true predicate, conditionally set non-true predicate
	for BB.

gcc/testsuite/

	PR tree-optimization/63941
	* gcc.dg/torture/pr63941.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr63941.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-if-conv.c
Comment 4 Jakub Jelinek 2014-12-01 12:47:21 UTC
Fixed.