Commit c4d825b5 by Richard Biener Committed by Richard Biener

tree-vect-loop.c (vect_analyze_loop_operations): Use auto_vec for cost vector to fix memleak.

2019-01-22  Richard Biener  <rguenther@suse.de>

	* tree-vect-loop.c (vect_analyze_loop_operations): Use
	auto_vec for cost vector to fix memleak.
	(vectorize_fold_left_reduction): Properly gather SLP defs.
	(vectorizable_comparison): Do not swap operands to properly
	gather SLP defs.

From-SVN: r268137
parent 8fcc3599
2019-01-22 Richard Biener <rguenther@suse.de>
* tree-vect-loop.c (vect_analyze_loop_operations): Use
auto_vec for cost vector to fix memleak.
(vectorize_fold_left_reduction): Properly gather SLP defs.
(vectorizable_comparison): Do not swap operands to properly
gather SLP defs.
2019-01-22 Alan Modra <amodra@gmail.com> 2019-01-22 Alan Modra <amodra@gmail.com>
PR target/88614 PR target/88614
......
...@@ -1470,8 +1470,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) ...@@ -1470,8 +1470,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
DUMP_VECT_SCOPE ("vect_analyze_loop_operations"); DUMP_VECT_SCOPE ("vect_analyze_loop_operations");
stmt_vector_for_cost cost_vec; auto_vec<stmt_info_for_cost> cost_vec;
cost_vec.create (2);
for (i = 0; i < nbbs; i++) for (i = 0; i < nbbs; i++)
{ {
...@@ -1581,7 +1580,6 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) ...@@ -1581,7 +1580,6 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
} /* bbs */ } /* bbs */
add_stmt_costs (loop_vinfo->target_cost_data, &cost_vec); add_stmt_costs (loop_vinfo->target_cost_data, &cost_vec);
cost_vec.release ();
/* All operations in the loop are either irrelevant (deal with loop /* All operations in the loop are either irrelevant (deal with loop
control, or dead), or only used outside the loop and can be moved control, or dead), or only used outside the loop and can be moved
...@@ -5742,8 +5740,14 @@ vectorize_fold_left_reduction (stmt_vec_info stmt_info, ...@@ -5742,8 +5740,14 @@ vectorize_fold_left_reduction (stmt_vec_info stmt_info,
auto_vec<tree> vec_oprnds0; auto_vec<tree> vec_oprnds0;
if (slp_node) if (slp_node)
{ {
vect_get_vec_defs (op0, NULL_TREE, stmt_info, &vec_oprnds0, NULL, auto_vec<vec<tree> > vec_defs (2);
slp_node); auto_vec<tree> sops(2);
sops.quick_push (ops[0]);
sops.quick_push (ops[1]);
vect_get_slp_defs (sops, slp_node, &vec_defs);
vec_oprnds0.safe_splice (vec_defs[1 - reduc_index]);
vec_defs[0].release ();
vec_defs[1].release ();
group_size = SLP_TREE_SCALAR_STMTS (slp_node).length (); group_size = SLP_TREE_SCALAR_STMTS (slp_node).length ();
scalar_dest_def_info = SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1]; scalar_dest_def_info = SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1];
} }
......
...@@ -9258,6 +9258,7 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -9258,6 +9258,7 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
BITOP2 (rhs1 BITOP1 rhs2) or BITOP2 (rhs1 BITOP1 rhs2) or
rhs1 BITOP2 (BITOP1 rhs2) rhs1 BITOP2 (BITOP1 rhs2)
depending on bitop1 and bitop2 arity. */ depending on bitop1 and bitop2 arity. */
bool swap_p = false;
if (VECTOR_BOOLEAN_TYPE_P (vectype)) if (VECTOR_BOOLEAN_TYPE_P (vectype))
{ {
if (code == GT_EXPR) if (code == GT_EXPR)
...@@ -9274,15 +9275,13 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -9274,15 +9275,13 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
{ {
bitop1 = BIT_NOT_EXPR; bitop1 = BIT_NOT_EXPR;
bitop2 = BIT_AND_EXPR; bitop2 = BIT_AND_EXPR;
std::swap (rhs1, rhs2); swap_p = true;
std::swap (dts[0], dts[1]);
} }
else if (code == LE_EXPR) else if (code == LE_EXPR)
{ {
bitop1 = BIT_NOT_EXPR; bitop1 = BIT_NOT_EXPR;
bitop2 = BIT_IOR_EXPR; bitop2 = BIT_IOR_EXPR;
std::swap (rhs1, rhs2); swap_p = true;
std::swap (dts[0], dts[1]);
} }
else else
{ {
...@@ -9349,6 +9348,8 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -9349,6 +9348,8 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
vect_get_slp_defs (ops, slp_node, &vec_defs); vect_get_slp_defs (ops, slp_node, &vec_defs);
vec_oprnds1 = vec_defs.pop (); vec_oprnds1 = vec_defs.pop ();
vec_oprnds0 = vec_defs.pop (); vec_oprnds0 = vec_defs.pop ();
if (swap_p)
std::swap (vec_oprnds0, vec_oprnds1);
} }
else else
{ {
...@@ -9368,6 +9369,8 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -9368,6 +9369,8 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
if (!slp_node) if (!slp_node)
{ {
if (swap_p)
std::swap (vec_rhs1, vec_rhs2);
vec_oprnds0.quick_push (vec_rhs1); vec_oprnds0.quick_push (vec_rhs1);
vec_oprnds1.quick_push (vec_rhs2); vec_oprnds1.quick_push (vec_rhs2);
} }
......
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