Commit e5f0e041 by Richard Biener Committed by Richard Biener

re PR tree-optimization/88148 (ICE in tree_nop_conversion_p at gcc/tree.c:12550 since r264273)

2018-11-22  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/88148
	* tree-ssa-loop-niter.c (simplify_replace_tree): Get optional
	valueization callback parameter and handle it.
	* tree-ssa-loop-niter.h (simplify_replace_tree): Export.
	* tree-ssa-sccvn.c (process_bb): Eliminate in loop niter trees.

	* gfortran.dg/pr88148.f90: New testcase.

From-SVN: r266378
parent 9479946c
2018-11-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/88148
* tree-ssa-loop-niter.c (simplify_replace_tree): Get optional
valueization callback parameter and handle it.
* tree-ssa-loop-niter.h (simplify_replace_tree): Export.
* tree-ssa-sccvn.c (process_bb): Eliminate in loop niter trees.
2018-11-22 Richard Biener <rguenther@suse.de>
PR lto/87229
PR lto/88112
* lto-streamer-out.c (lto_is_streamable): Allow CALL_EXPRs
2018-11-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/88148
* gfortran.dg/pr88148.f90: New testcase.
2018-11-22 Andreas Schwab <schwab@suse.de>
* g++.dg/lto/odr-2_0.C: Remove extra brace
......
......@@ -1919,10 +1919,14 @@ number_of_iterations_cond (struct loop *loop,
return ret;
}
/* Substitute NEW for OLD in EXPR and fold the result. */
/* Substitute NEW_TREE for OLD in EXPR and fold the result.
If VALUEIZE is non-NULL then OLD and NEW_TREE are ignored and instead
all SSA names are replaced with the result of calling the VALUEIZE
function with the SSA name as argument. */
static tree
simplify_replace_tree (tree expr, tree old, tree new_tree)
tree
simplify_replace_tree (tree expr, tree old, tree new_tree,
tree (*valueize) (tree))
{
unsigned i, n;
tree ret = NULL_TREE, e, se;
......@@ -1931,11 +1935,20 @@ simplify_replace_tree (tree expr, tree old, tree new_tree)
return NULL_TREE;
/* Do not bother to replace constants. */
if (CONSTANT_CLASS_P (old))
if (CONSTANT_CLASS_P (expr))
return expr;
if (expr == old
|| operand_equal_p (expr, old, 0))
if (valueize)
{
if (TREE_CODE (expr) == SSA_NAME)
{
new_tree = valueize (expr);
if (new_tree != expr)
return new_tree;
}
}
else if (expr == old
|| operand_equal_p (expr, old, 0))
return unshare_expr (new_tree);
if (!EXPR_P (expr))
......@@ -1945,7 +1958,7 @@ simplify_replace_tree (tree expr, tree old, tree new_tree)
for (i = 0; i < n; i++)
{
e = TREE_OPERAND (expr, i);
se = simplify_replace_tree (e, old, new_tree);
se = simplify_replace_tree (e, old, new_tree, valueize);
if (e == se)
continue;
......
......@@ -53,6 +53,7 @@ extern bool scev_probably_wraps_p (tree, tree, tree, gimple *,
struct loop *, bool);
extern void free_numbers_of_iterations_estimates (struct loop *);
extern void free_numbers_of_iterations_estimates (function *);
extern tree simplify_replace_tree (tree, tree, tree, tree (*)(tree) = NULL);
extern void substitute_in_loop_info (struct loop *, tree, tree);
#endif /* GCC_TREE_SSA_LOOP_NITER_H */
......@@ -68,6 +68,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-cfgcleanup.h"
#include "tree-ssa-loop.h"
#include "tree-scalar-evolution.h"
#include "tree-ssa-loop-niter.h"
#include "tree-ssa-sccvn.h"
/* This algorithm is based on the SCC algorithm presented by Keith
......@@ -5904,6 +5905,16 @@ process_bb (rpo_elim &avail, basic_block bb,
break;
}
/* When we visit a loop header substitute into loop info. */
if (!iterate && eliminate && bb->loop_father->header == bb)
{
/* Keep fields in sync with substitute_in_loop_info. */
if (bb->loop_father->nb_iterations)
bb->loop_father->nb_iterations
= simplify_replace_tree (bb->loop_father->nb_iterations,
NULL_TREE, NULL_TREE, vn_valueize);
}
/* Value-number all defs in the basic-block. */
for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
gsi_next (&gsi))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment