Bug 47157 - [4.6 Regression] ICE: in calc_dfs_tree, at dominance.c:395 with -O
Summary: [4.6 Regression] ICE: in calc_dfs_tree, at dominance.c:395 with -O
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-on-valid-code, patch
Depends on: 46755
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-03 10:17 UTC by Jakub Jelinek
Modified: 2011-01-03 21:11 UTC (History)
4 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-01-03 10:33:41


Attachments
gcc46-pr47157.patch (674 bytes, patch)
2011-01-03 10:33 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2011-01-03 10:17:15 UTC
+++ This bug was initially created as a clone of Bug #46755 +++

PR46755#c8 is unrelated bug to the original one, so creating a separate PR for it:

Not sure if this is still useful, but here's a fairly small failure-inducing
testcase for this bug for today's GCC.

[regehr@gamow tmp437]$ current-gcc -O2 -c small.c

small.c: In function 'func':
small.c:32:1: internal compiler error: in calc_dfs_tree, at dominance.c:395
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@gamow tmp437]$ current-gcc -v

Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r168402-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r168402-install
--program-prefix=r168402- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20110102 (experimental) (GCC) 

[regehr@gamow tmp437]$ cat small.c


static int
foo (int si1, short si2)
{
  return ((si1 ^ si2) & ((si1 ^ (si1 ^ si2) & ~2147483647) - si2 ^ si2)) <
    0 ? si1 : si1 - si2;
}

struct S0
{
  const unsigned f3:1;
  const unsigned f8:1;
};
struct S0 g_111 = {
  1
};

struct S0 g_139 = {
  1
};

unsigned long int g_22;

void safe (int);
int func_42 (void);

void func (void)
{
  safe (foo (func_42 () != (g_139.f3 | g_111.f8), -1L));
  for (g_22 = 0; g_22; g_22 = 1)
    {
    }
}

This is caused by revision 164431:

http://gcc.gnu.org/ml/gcc-cvs/2010-09/msg00727.html
Comment 1 Jakub Jelinek 2011-01-03 10:33:40 UTC
Created attachment 22885 [details]
gcc46-pr47157.patch

Untested fix.
Comment 2 Jakub Jelinek 2011-01-03 20:59:25 UTC
Author: jakub
Date: Mon Jan  3 20:59:20 2011
New Revision: 168439

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168439
Log:
	PR rtl-optimization/47157
	* combine.c (try_combine): If undobuf.other_insn becomes
	(set (pc) (pc)) jump, call update_cfg_for_uncondjump on it
	and set *new_direct_jump_p too.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr47157.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Jakub Jelinek 2011-01-03 21:11:29 UTC
Fixed.