re PR tree-optimization/59139 (internal compiler error: in get_val_for, at tree-ssa-loop-niter.c:2267)

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.

From-SVN: r205588
This commit is contained in:
Richard Biener 2013-12-02 15:43:01 +00:00 committed by Richard Biener
parent 75fcf2876f
commit 100f09a564
4 changed files with 37 additions and 3 deletions

View file

@ -1,5 +1,13 @@
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.
2013-12-02 Richard Biener <rguenther@suse.de>
PR middle-end/59199
* tree-ssa-operands.c (opf_implicit): Remove.
(opf_address_taken): New flag.
(get_expr_operands): Remove early out, pass down

View file

@ -1,3 +1,8 @@
2013-12-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/59139
* gcc.dg/torture/pr59139.c: New testcase.
2013-12-02 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt30.adb: New test.

View file

@ -0,0 +1,20 @@
/* { dg-do compile } */
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;
}
}
}

View file

@ -2167,7 +2167,8 @@ chain_of_csts_start (struct loop *loop, tree x)
return NULL;
}
if (gimple_code (stmt) != GIMPLE_ASSIGN)
if (gimple_code (stmt) != GIMPLE_ASSIGN
|| gimple_assign_rhs_class (stmt) == GIMPLE_TERNARY_RHS)
return NULL;
code = gimple_assign_rhs_code (stmt);
@ -2235,7 +2236,7 @@ get_val_for (tree x, tree base)
{
gimple stmt;
gcc_assert (is_gimple_min_invariant (base));
gcc_checking_assert (is_gimple_min_invariant (base));
if (!x)
return base;
@ -2244,7 +2245,7 @@ get_val_for (tree x, tree base)
if (gimple_code (stmt) == GIMPLE_PHI)
return base;
gcc_assert (is_gimple_assign (stmt));
gcc_checking_assert (is_gimple_assign (stmt));
/* STMT must be either an assignment of a single SSA name or an
expression involving an SSA name and a constant. Try to fold that