diff options
author | Richard Biener <rguenther@suse.de> | 2019-02-08 13:21:36 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-02-08 13:21:36 +0000 |
commit | a2d0c3bf8c4487249aae1e2b1927d71703bfcda4 (patch) | |
tree | 2bc0646c56aa7a909d392e2a090b45f5e17c3c5a /gcc/tree-if-conv.c | |
parent | 11719d1474c6dbd574867646b7c53f9719abc178 (diff) | |
download | gcc-a2d0c3bf8c4487249aae1e2b1927d71703bfcda4.zip gcc-a2d0c3bf8c4487249aae1e2b1927d71703bfcda4.tar.gz gcc-a2d0c3bf8c4487249aae1e2b1927d71703bfcda4.tar.bz2 |
re PR tree-optimization/89247 (ICE in expand_LOOP_VECTORIZED, at internal-fn.c:2409)
2019-02-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/89247
* tree-if-conv.c: Include tree-cfgcleanup.h.
(version_loop_for_if_conversion): Record LOOP_VECTORIZED call.
(tree_if_conversion): Pass through predicate vector.
(pass_if_conversion::execute): Do CFG cleanup and SSA update
inline, see if any if-converted loops we refrece in
LOOP_VECTORIZED calls vanished and fixup.
* tree-if-conv.h (tree_if_conversion): Adjust prototype.
* gcc.dg/torture/pr89247.c: New testcase.
From-SVN: r268689
Diffstat (limited to 'gcc/tree-if-conv.c')
-rw-r--r-- | gcc/tree-if-conv.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index bdd4c2a..cfeaec7 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -119,6 +119,7 @@ along with GCC; see the file COPYING3. If not see #include "internal-fn.h" #include "fold-const.h" #include "tree-ssa-sccvn.h" +#include "tree-cfgcleanup.h" /* Only handle PHIs with no more arguments unless we are asked to by simd pragma. */ @@ -2719,7 +2720,7 @@ combine_blocks (struct loop *loop) consistent after the condition is folded in the vectorizer. */ static struct loop * -version_loop_for_if_conversion (struct loop *loop) +version_loop_for_if_conversion (struct loop *loop, vec<gimple *> *preds) { basic_block cond_bb; tree cond = make_ssa_name (boolean_type_node); @@ -2759,6 +2760,7 @@ version_loop_for_if_conversion (struct loop *loop) new_loop->force_vectorize = false; gsi = gsi_last_bb (cond_bb); gimple_call_set_arg (g, 1, build_int_cst (integer_type_node, new_loop->num)); + preds->safe_push (g); gsi_insert_before (&gsi, g, GSI_SAME_STMT); update_ssa (TODO_update_ssa); return new_loop; @@ -2979,7 +2981,7 @@ ifcvt_local_dce (basic_block bb) changed. */ unsigned int -tree_if_conversion (struct loop *loop) +tree_if_conversion (struct loop *loop, vec<gimple *> *preds) { unsigned int todo = 0; bool aggressive_if_conv; @@ -3027,7 +3029,7 @@ tree_if_conversion (struct loop *loop) struct loop *vloop = (versionable_outer_loop_p (loop_outer (loop)) ? loop_outer (loop) : loop); - struct loop *nloop = version_loop_for_if_conversion (vloop); + struct loop *nloop = version_loop_for_if_conversion (vloop, preds); if (nloop == NULL) goto cleanup; if (vloop != loop) @@ -3139,11 +3141,12 @@ pass_if_conversion::execute (function *fun) if (number_of_loops (fun) <= 1) return 0; + auto_vec<gimple *> preds; FOR_EACH_LOOP (loop, 0) if (flag_tree_loop_if_convert == 1 || ((flag_tree_loop_vectorize || loop->force_vectorize) && !loop->dont_vectorize)) - todo |= tree_if_conversion (loop); + todo |= tree_if_conversion (loop, &preds); if (todo) { @@ -3158,7 +3161,30 @@ pass_if_conversion::execute (function *fun) gcc_assert (!bb->aux); } - return todo; + /* Perform IL update now, it might elide some loops. */ + if (todo & TODO_cleanup_cfg) + { + cleanup_tree_cfg (); + if (need_ssa_update_p (fun)) + todo |= TODO_update_ssa; + } + if (todo & TODO_update_ssa_any) + update_ssa (todo & TODO_update_ssa_any); + + /* If if-conversion elided the loop fall back to the original one. */ + for (unsigned i = 0; i < preds.length (); ++i) + { + gimple *g = preds[i]; + unsigned ifcvt_loop = tree_to_uhwi (gimple_call_arg (g, 0)); + if (!get_loop (fun, ifcvt_loop)) + { + if (dump_file) + fprintf (dump_file, "If-converted loop vanished\n"); + fold_loop_internal_call (g, boolean_false_node); + } + } + + return 0; } } // anon namespace |