Bug 59139 - [4.7 Regression] internal compiler error: in get_val_for, at tree-ssa-loop-niter.c:2267
Summary: [4.7 Regression] internal compiler error: in get_val_for, at tree-ssa-loop-ni...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.9.0
: P2 normal
Target Milestone: 4.7.4
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-14 23:13 UTC by John Regehr
Modified: 2014-03-17 14:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.4, 4.8.3, 4.9.0
Known to fail: 4.7.3, 4.8.2
Last reconfirmed: 2013-11-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2013-11-14 23:13:08 UTC
[regehr@imp test]$ gcc -O3 -c -Wall ./work20/reduce_55RZFl/small.c
./work20/reduce_55RZFl/small.c: In function âfn2â:
./work20/reduce_55RZFl/small.c:4:6: internal compiler error: in get_val_for, at tree-ssa-loop-niter.c:2267
 void fn2() {
      ^
0xafe7c9 get_val_for
	/users/regehr/z/compiler-source/gcc/gcc/tree-ssa-loop-niter.c:2267
0xb0162b loop_niter_by_eval(loop*, edge_def*)
	/users/regehr/z/compiler-source/gcc/gcc/tree-ssa-loop-niter.c:2335
0xb01934 find_loop_niter_by_eval(loop*, edge_def**)
	/users/regehr/z/compiler-source/gcc/gcc/tree-ssa-loop-niter.c:2394
0xae4c5f canonicalize_loop_induction_variables
	/users/regehr/z/compiler-source/gcc/gcc/tree-ssa-loop-ivcanon.c:929
0xae682b canonicalize_induction_variables()
	/users/regehr/z/compiler-source/gcc/gcc/tree-ssa-loop-ivcanon.c:998
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.
[regehr@imp test]$ cat ./work20/reduce_55RZFl/small.c
int a, b, c, d, e;
int fn1(p1, p2) { return p2 == 0 ? p1 : 1 % p2; }

void fn2() {
  c = 0;
  for (;; c = (unsigned short)c) {
    b = 2;
    for (; b; b = a) {
      e = fn1(2, c && 1);
      d = c == 0 ? e : c;
      if (d)
        return;
    }
  }
}
[regehr@imp test]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/mnt/local/randomtest/compiler-install/gcc-r204770-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /users/regehr/z/compiler-source/gcc/configure --prefix=/users/regehr/z/compiler-install/gcc-r204770-install --enable-languages=c,c++ --enable-multilib
Thread model: posix
gcc version 4.9.0 20131114 (experimental) (GCC)
Comment 1 Richard Biener 2013-11-15 09:16:26 UTC
Confirmed.

(gdb) call debug_gimple_stmt (stmt)
Comment 2 Mikael Pettersson 2013-11-16 19:58:21 UTC
Started with r173612.
Comment 3 Richard Biener 2013-11-21 14:46:34 UTC
I can't reproduce it anymore and wonder what fixed it.  Likely some constant
folding.

I wonder if a more appropriate fix would be to drop the gcc_unreachable ()
and just fold the thing.

I'll have a look.
Comment 4 Richard Biener 2013-12-02 15:43:03 UTC
Author: rguenth
Date: Mon Dec  2 15:43:01 2013
New Revision: 205588

URL: http://gcc.gnu.org/viewcvs?rev=205588&root=gcc&view=rev
Log:
2013-12-02  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59139
	* tree-ssa-loop-niter.c (chain_of_csts_start): Properly match
	code in get_val_for.
	(get_val_for): Use gcc_checking_asserts.

	* gcc.dg/torture/pr59139.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr59139.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-loop-niter.c
Comment 5 Richard Biener 2013-12-02 15:43:48 UTC
Author: rguenth
Date: Mon Dec  2 15:43:47 2013
New Revision: 205589

URL: http://gcc.gnu.org/viewcvs?rev=205589&root=gcc&view=rev
Log:
2013-12-02  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59139
	* tree-ssa-loop-niter.c (chain_of_csts_start): Properly match
	code in get_val_for.
	(get_val_for): Use gcc_checking_asserts.

	* gcc.dg/torture/pr59139.c: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr59139.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-ssa-loop-niter.c
Comment 6 Richard Biener 2013-12-02 15:44:17 UTC
Fixed for 4.8.3 sofar.
Comment 7 Richard Biener 2014-03-17 14:39:27 UTC
Author: rguenth
Date: Mon Mar 17 14:38:55 2014
New Revision: 208618

URL: http://gcc.gnu.org/viewcvs?rev=208618&root=gcc&view=rev
Log:
2014-03-17  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2013-05-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/57303
	* tree-ssa-sink.c (statement_sink_location): Properly handle
	self-assignments.

	* gcc.dg/torture/pr57303.c: New testcase.

	2013-12-02  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59139
	* tree-ssa-loop-niter.c (chain_of_csts_start): Properly match
	code in get_val_for.
	(get_val_for): Use gcc_checking_asserts.

	* gcc.dg/torture/pr59139.c: New testcase.

	2014-02-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/60183
	* tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating
	loads.
	(tree_ssa_phiprop): Calculate and free post-dominators.

	* gcc.dg/torture/pr60183.c: New testcase.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr57303.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr59139.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr60183.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-ssa-loop-niter.c
    branches/gcc-4_7-branch/gcc/tree-ssa-phiprop.c
    branches/gcc-4_7-branch/gcc/tree-ssa-sink.c
Comment 8 Richard Biener 2014-03-17 14:40:05 UTC
Fixed.