aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-07-18 07:26:04 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-07-18 07:26:04 +0000
commitd2e78d766294a5e548c2eaf92f07a8f768120e1c (patch)
tree9f3dd6f500bb84223c8af23792329fe80a0a3630 /gcc
parent651dbe5d8e8e4907af30fb319c6ca0d29269b1e1 (diff)
downloadgcc-d2e78d766294a5e548c2eaf92f07a8f768120e1c.zip
gcc-d2e78d766294a5e548c2eaf92f07a8f768120e1c.tar.gz
gcc-d2e78d766294a5e548c2eaf92f07a8f768120e1c.tar.bz2
re PR tree-optimization/81418 (ICE in vect_get_vec_def_for_stmt_copy)
2017-06-18 Richard Biener <rguenther@suse.de> PR tree-optimization/81418 * tree-vect-loop.c (vectorizable_reduction): Properly compute vectype_in. Verify that with lane-reducing reduction operations we have a single def-use cycle. * gcc.dg/torture/pr81418.c: New testcase. From-SVN: r250296
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr81418.c19
-rw-r--r--gcc/tree-vect-loop.c60
4 files changed, 68 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 80a02d1..dab4a95 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,9 @@
-gcc/ChangeLog:
+2017-06-18 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81418
+ * tree-vect-loop.c (vectorizable_reduction): Properly compute
+ vectype_in. Verify that with lane-reducing reduction operations
+ we have a single def-use cycle.
2017-07-17 Carl Love <cel@us.ibm.com>
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4bbc174..10951f5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,7 @@
-gcc/testsuite/ChangeLog:
+2017-06-18 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81418
+ * gcc.dg/torture/pr81418.c: New testcase.
2017-07-17 Carl Love <cel@us.ibm.com>
diff --git a/gcc/testsuite/gcc.dg/torture/pr81418.c b/gcc/testsuite/gcc.dg/torture/pr81418.c
new file mode 100644
index 0000000..245861b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr81418.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-loop-optimize" } */
+
+int
+ol (int ku)
+{
+ int zq = 0;
+
+ while (ku < 1)
+ {
+ int y6;
+
+ for (y6 = 0; y6 < 3; ++y6)
+ zq += (char)ku;
+ ++ku;
+ }
+
+ return zq;
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 6c18c8f..08c56ce 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -5642,7 +5642,10 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
if (k == 1
&& gimple_assign_rhs_code (reduc_stmt) == COND_EXPR)
continue;
- vectype_in = get_vectype_for_scalar_type (TREE_TYPE (op));
+ tem = get_vectype_for_scalar_type (TREE_TYPE (op));
+ if (! vectype_in
+ || TYPE_VECTOR_SUBPARTS (tem) < TYPE_VECTOR_SUBPARTS (vectype_in))
+ vectype_in = tem;
break;
}
gcc_assert (vectype_in);
@@ -6213,26 +6216,6 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
}
}
- if (!vec_stmt) /* transformation not required. */
- {
- if (first_p)
- vect_model_reduction_cost (stmt_info, epilog_reduc_code, ncopies);
- STMT_VINFO_TYPE (stmt_info) = reduc_vec_info_type;
- return true;
- }
-
- /* Transform. */
-
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location, "transform reduction.\n");
-
- /* FORNOW: Multiple types are not supported for condition. */
- if (code == COND_EXPR)
- gcc_assert (ncopies == 1);
-
- /* Create the destination vector */
- vec_dest = vect_create_destination_var (scalar_dest, vectype_out);
-
/* In case the vectorization factor (VF) is bigger than the number
of elements that we can fit in a vectype (nunits), we have to generate
more than one vector stmt - i.e - we need to "unroll" the
@@ -6276,6 +6259,41 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
else
epilog_copies = ncopies;
+ /* If the reduction stmt is one of the patterns that have lane
+ reduction embedded we cannot handle the case of ! single_defuse_cycle. */
+ if ((ncopies > 1
+ && ! single_defuse_cycle)
+ && (code == DOT_PROD_EXPR
+ || code == WIDEN_SUM_EXPR
+ || code == SAD_EXPR))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "multi def-use cycle not possible for lane-reducing "
+ "reduction operation\n");
+ return false;
+ }
+
+ if (!vec_stmt) /* transformation not required. */
+ {
+ if (first_p)
+ vect_model_reduction_cost (stmt_info, epilog_reduc_code, ncopies);
+ STMT_VINFO_TYPE (stmt_info) = reduc_vec_info_type;
+ return true;
+ }
+
+ /* Transform. */
+
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location, "transform reduction.\n");
+
+ /* FORNOW: Multiple types are not supported for condition. */
+ if (code == COND_EXPR)
+ gcc_assert (ncopies == 1);
+
+ /* Create the destination vector */
+ vec_dest = vect_create_destination_var (scalar_dest, vectype_out);
+
prev_stmt_info = NULL;
prev_phi_info = NULL;
if (slp_node)