diff options
author | Richard Biener <rguenther@suse.de> | 2018-11-22 14:08:44 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-11-22 14:08:44 +0000 |
commit | e5f0e0412b9aa61d960ffbb83327415da226f266 (patch) | |
tree | d266b058a6df69881af86beaa6a61db1bd683569 /gcc/tree-ssa-loop-niter.c | |
parent | 9479946c1fc1177c4709115c454b91395092e0db (diff) | |
download | gcc-e5f0e0412b9aa61d960ffbb83327415da226f266.zip gcc-e5f0e0412b9aa61d960ffbb83327415da226f266.tar.gz gcc-e5f0e0412b9aa61d960ffbb83327415da226f266.tar.bz2 |
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
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 67a3d68..78165f3 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -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; |