aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-12-16 09:21:04 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-12-16 09:21:04 +0000
commit8155f4d8cfd834e7cf1151a41fe0773477504f48 (patch)
treef07259795a95fb33927fe7bbf78d27801c03abe6
parent8ec0963c81b2023596d1c9913571c2c462f06796 (diff)
downloadgcc-8155f4d8cfd834e7cf1151a41fe0773477504f48.zip
gcc-8155f4d8cfd834e7cf1151a41fe0773477504f48.tar.gz
gcc-8155f4d8cfd834e7cf1151a41fe0773477504f48.tar.bz2
re PR tree-optimization/68892 (Excessive dead loads produced by BB vectorization)
2015-12-16 Richard Biener <rguenther@suse.de> PR tree-optimization/68892 * tree-vect-slp.c (vect_analyze_slp_cost_1): Properly compute cost for permuted loads. * gcc.dg/vect/bb-slp-pr68892.c: New testcase. From-SVN: r231674
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c16
-rw-r--r--gcc/tree-vect-slp.c48
4 files changed, 48 insertions, 27 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c68fd13..6450d52 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-16 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/68892
+ * tree-vect-slp.c (vect_analyze_slp_cost_1): Properly compute
+ cost for permuted loads.
+
2015-12-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/65980
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a0b8fda..7a3c5e4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-16 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/68892
+ * gcc.dg/vect/bb-slp-pr68892.c: New testcase.
+
2015-12-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/65980
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c
new file mode 100644
index 0000000..648fe481
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fvect-cost-model=dynamic" } */
+
+double a[128][128];
+double b[128];
+
+void foo(void)
+{
+ b[0] = a[0][0];
+ b[1] = a[1][0];
+ b[2] = a[2][0];
+ b[3] = a[3][0];
+}
+
+/* { dg-final { scan-tree-dump "not profitable" "slp2" } } */
+/* { dg-final { scan-tree-dump-times "Basic block will be vectorized" 0 "slp2" } } */
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 3fdc988..f57c859 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1402,10 +1402,9 @@ vect_analyze_slp_cost_1 (slp_instance instance, slp_tree node,
{
unsigned i, j;
slp_tree child;
- gimple *stmt, *s;
+ gimple *stmt;
stmt_vec_info stmt_info;
tree lhs;
- unsigned group_size = SLP_INSTANCE_GROUP_SIZE (instance);
/* Recurse down the SLP tree. */
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
@@ -1424,44 +1423,39 @@ vect_analyze_slp_cost_1 (slp_instance instance, slp_tree node,
node, prologue_cost_vec, body_cost_vec);
else
{
- int i;
gcc_checking_assert (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)));
- /* If the load is permuted then the alignment is determined by
- the first group element not by the first scalar stmt DR. */
if (SLP_TREE_LOAD_PERMUTATION (node).exists ())
{
+ /* If the load is permuted then the alignment is determined by
+ the first group element not by the first scalar stmt DR. */
stmt = GROUP_FIRST_ELEMENT (stmt_info);
stmt_info = vinfo_for_stmt (stmt);
+ /* Record the cost for the permutation. */
+ record_stmt_cost (body_cost_vec, ncopies_for_cost, vec_perm,
+ stmt_info, 0, vect_body);
+ /* And adjust the number of loads performed. */
+ unsigned nunits
+ = TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info));
+ ncopies_for_cost
+ = (GROUP_SIZE (stmt_info) - GROUP_GAP (stmt_info)
+ + nunits - 1) / nunits;
+ ncopies_for_cost *= SLP_INSTANCE_UNROLLING_FACTOR (instance);
}
+ /* Record the cost for the vector loads. */
vect_model_load_cost (stmt_info, ncopies_for_cost, false,
node, prologue_cost_vec, body_cost_vec);
- /* If the load is permuted record the cost for the permutation.
- ??? Loads from multiple chains are let through here only
- for a single special case involving complex numbers where
- in the end no permutation is necessary. */
- FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, s)
- if ((STMT_VINFO_GROUP_FIRST_ELEMENT (vinfo_for_stmt (s))
- == STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_info))
- && vect_get_place_in_interleaving_chain
- (s, STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_info)) != i)
- {
- record_stmt_cost (body_cost_vec, group_size, vec_perm,
- stmt_info, 0, vect_body);
- break;
- }
}
+ return;
}
- else
+
+ record_stmt_cost (body_cost_vec, ncopies_for_cost, vector_stmt,
+ stmt_info, 0, vect_body);
+ if (SLP_TREE_TWO_OPERATORS (node))
{
record_stmt_cost (body_cost_vec, ncopies_for_cost, vector_stmt,
stmt_info, 0, vect_body);
- if (SLP_TREE_TWO_OPERATORS (node))
- {
- record_stmt_cost (body_cost_vec, ncopies_for_cost, vector_stmt,
- stmt_info, 0, vect_body);
- record_stmt_cost (body_cost_vec, ncopies_for_cost, vec_perm,
- stmt_info, 0, vect_body);
- }
+ record_stmt_cost (body_cost_vec, ncopies_for_cost, vec_perm,
+ stmt_info, 0, vect_body);
}
/* Push SLP node def-type to stmts. */