From f7dff7699fd70d3b8c3e637818e18c86f93ccfec Mon Sep 17 00:00:00 2001 From: Andre Vieira Date: Thu, 16 Jan 2020 10:28:02 +0000 Subject: PR tree-optimization/92429 do not fold when updating epilogue statements This patch addresses the problem reported in PR92429. When creating an epilogue for vectorization we have to replace the SSA_NAMEs in the PATTERN_DEF_SEQs and RELATED_STMTs of the epilogue's loop_vec_infos. When doing this we were using simplify_replace_tree which always folds the replacement. This may lead to a different tree-node than the one which was analyzed in vect_loop_analyze. In turn the new tree-node may require a different vectorization than the one we had prepared for which caused the ICE in question. gcc/ChangeLog: 2020-01-16 Andre Vieira PR tree-optimization/92429 * tree-ssa-loop-niter.h (simplify_replace_tree): Add parameter. * tree-ssa-loop-niter.c (simplify_replace_tree): Add parameter to control folding. * tree-vect-loop.c (update_epilogue_vinfo): Do not fold when replacing tree. gcc/testsuite/ChangeLog: 2020-01-16 Andre Vieira PR tree-optimization/92429 * gcc.dg/vect/pr92429.c: New test. --- gcc/tree-ssa-loop-niter.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-niter.c') diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 4d5e0494511..6e6df0bfdb8 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1934,7 +1934,8 @@ number_of_iterations_cond (class loop *loop, tree simplify_replace_tree (tree expr, tree old, tree new_tree, - tree (*valueize) (tree, void*), void *context) + tree (*valueize) (tree, void*), void *context, + bool do_fold) { unsigned i, n; tree ret = NULL_TREE, e, se; @@ -1966,7 +1967,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, valueize, context); + se = simplify_replace_tree (e, old, new_tree, valueize, context, do_fold); if (e == se) continue; @@ -1976,7 +1977,7 @@ simplify_replace_tree (tree expr, tree old, tree new_tree, TREE_OPERAND (ret, i) = se; } - return (ret ? fold (ret) : expr); + return (ret ? (do_fold ? fold (ret) : ret) : expr); } /* Expand definitions of ssa names in EXPR as long as they are simple -- cgit v1.2.3