re PR tree-optimization/71059 (gcc ICE at -O3 on valid code on x86_64-linux-gnu in "vn_nary_op_insert_into")

2016-05-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/71059
	* tree-ssa-pre.c (phi_translate_1): Fully fold translated
	nary before looking up or entering the expression into the VN
	hashes.
	* tree-ssa-sccvn.c (vn_nary_build_or_lookup): Fix comment typo.
	Make sure to re-use NARYs without result as inserted by
	phi-translation.

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

From-SVN: r236175
This commit is contained in:
Richard Biener 2016-05-12 13:46:26 +00:00 committed by Richard Biener
parent 763baff6f5
commit 1ef33ef304
5 changed files with 48 additions and 9 deletions

View File

@ -1,3 +1,13 @@
2016-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/71059
* tree-ssa-pre.c (phi_translate_1): Fully fold translated
nary before looking up or entering the expression into the VN
hashes.
* tree-ssa-sccvn.c (vn_nary_build_or_lookup): Fix comment typo.
Make sure to re-use NARYs without result as inserted by
phi-translation.
2016-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/71062

View File

@ -1,3 +1,8 @@
2016-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/71059
* gcc.dg/torture/pr71059.c: New testcase.
2016-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/71062

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
short a, c;
union {
unsigned f0;
unsigned short f1;
} b;
volatile int d;
short fn1(short p1) { return p1 + a; }
void fn2()
{
b.f0 = 0;
for (;; b.f0 = fn1(b.f0))
(c && b.f1) || d;
}

View File

@ -1464,6 +1464,12 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
pre_expr constant;
unsigned int new_val_id;
PRE_EXPR_NARY (expr) = newnary;
constant = fully_constant_expression (expr);
PRE_EXPR_NARY (expr) = nary;
if (constant != expr)
return constant;
tree result = vn_nary_op_lookup_pieces (newnary->length,
newnary->opcode,
newnary->type,
@ -1478,10 +1484,6 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
if (nary)
{
PRE_EXPR_NARY (expr) = nary;
constant = fully_constant_expression (expr);
if (constant != expr)
return constant;
new_val_id = nary->value_id;
get_or_alloc_expression_id (expr);
}
@ -1495,9 +1497,6 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
&newnary->op[0],
result, new_val_id);
PRE_EXPR_NARY (expr) = nary;
constant = fully_constant_expression (expr);
if (constant != expr)
return constant;
get_or_alloc_expression_id (expr);
}
add_to_value (new_val_id, expr);

View File

@ -1632,7 +1632,7 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops)
{
tree result = NULL_TREE;
/* We will be creating a value number for
ROCDE (OPS...).
RCODE (OPS...).
So first simplify and lookup this expression to see if it
is already available. */
mprts_hook = vn_lookup_simplify_result;
@ -1682,6 +1682,16 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops)
gimple_seq_add_stmt_without_update (&VN_INFO (result)->expr,
new_stmt);
VN_INFO (result)->needs_insertion = true;
/* ??? PRE phi-translation inserts NARYs without corresponding
SSA name result. Re-use those but set their result according
to the stmt we just built. */
vn_nary_op_t nary = NULL;
vn_nary_op_lookup_stmt (new_stmt, &nary);
if (nary)
{
gcc_assert (nary->result == NULL_TREE);
nary->result = gimple_assign_lhs (new_stmt);
}
/* As all "inserted" statements are singleton SCCs, insert
to the valid table. This is strictly needed to
avoid re-generating new value SSA_NAMEs for the same
@ -1689,7 +1699,7 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops)
optimistic table gets cleared after each iteration).
We do not need to insert into the optimistic table, as
lookups there will fall back to the valid table. */
if (current_info == optimistic_info)
else if (current_info == optimistic_info)
{
current_info = valid_info;
vn_nary_op_insert_stmt (new_stmt, result);