+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.
+
2019-02-08 Ilya Leoshkevich <iii@linux.ibm.com>
* config/s390/constraints.md (jdd): New constraint.
#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. */
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);
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;
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;
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)
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)
{
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