aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-19 07:33:58 +0000
committerRichard Biener <rguenther@suse.de>2019-11-19 07:33:58 +0000
commit04b1d143fc7719603543facbea3a06bda1a92586 (patch)
tree154dcc70eba849dbb1296239cbf2885314b172d0
parenta6e03a93634ebae8fbc42c3e6396dd87cf013c29 (diff)
2019-11-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/92554 * tree-vect-loop.c (vect_create_epilog_for_reduction): Look for the actual condition stmt and deal with sign-changes. * gcc.dg/vect/pr92554.c: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@278431 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr92554.c11
-rw-r--r--gcc/tree-vect-loop.c32
4 files changed, 45 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 98f5c2fc49c..3bd06229c64 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,10 @@
-2019-09-19 Richard Biener <rguenther@suse.de>
+2019-11-19 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92554
+ * tree-vect-loop.c (vect_create_epilog_for_reduction): Look
+ for the actual condition stmt and deal with sign-changes.
+
+2019-11-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/92555
* tree-vect-loop.c (vect_update_vf_for_slp): Also scan PHIs
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 05f38c2acd2..22b54da233c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,9 @@
-2019-09-19 Richard Biener <rguenther@suse.de>
+2019-11-19 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92554
+ * gcc.dg/vect/pr92554.c: New testcase.
+
+2019-11-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/92555
* gcc.dg/vect/pr92555.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/vect/pr92554.c b/gcc/testsuite/gcc.dg/vect/pr92554.c
new file mode 100644
index 00000000000..006375b1d24
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr92554.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+short int w9;
+
+void __attribute__ ((simd))
+zc (int in)
+{
+ int va = 1;
+
+ w9 *= va != 0 ? in < 0 : 0;
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 5ca6b551598..0e2b6462b4e 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -4552,12 +4552,21 @@ vect_create_epilog_for_reduction (stmt_vec_info stmt_info,
zeroes. */
if (STMT_VINFO_REDUC_TYPE (reduc_info) == COND_REDUCTION)
{
- tree indx_before_incr, indx_after_incr;
- poly_uint64 nunits_out = TYPE_VECTOR_SUBPARTS (vectype);
-
- gimple *vec_stmt = STMT_VINFO_VEC_STMT (stmt_info)->stmt;
+ stmt_vec_info cond_info = STMT_VINFO_REDUC_DEF (reduc_info);
+ cond_info = vect_stmt_to_vectorize (cond_info);
+ while (gimple_assign_rhs_code (cond_info->stmt) != COND_EXPR)
+ {
+ cond_info
+ = loop_vinfo->lookup_def (gimple_op (cond_info->stmt,
+ 1 + STMT_VINFO_REDUC_IDX
+ (cond_info)));
+ cond_info = vect_stmt_to_vectorize (cond_info);
+ }
+ gimple *vec_stmt = STMT_VINFO_VEC_STMT (cond_info)->stmt;
gcc_assert (gimple_assign_rhs_code (vec_stmt) == VEC_COND_EXPR);
+ tree indx_before_incr, indx_after_incr;
+ poly_uint64 nunits_out = TYPE_VECTOR_SUBPARTS (vectype);
int scalar_precision
= GET_MODE_PRECISION (SCALAR_TYPE_MODE (TREE_TYPE (vectype)));
tree cr_index_scalar_type = make_unsigned_type (scalar_precision);
@@ -4611,9 +4620,9 @@ vect_create_epilog_for_reduction (stmt_vec_info stmt_info,
(CCOMPARE). The then and else values mirror the main VEC_COND_EXPR:
the reduction phi corresponds to NEW_PHI_TREE and the new values
correspond to INDEX_BEFORE_INCR. */
- gcc_assert (STMT_VINFO_REDUC_IDX (stmt_info) >= 1);
+ gcc_assert (STMT_VINFO_REDUC_IDX (cond_info) >= 1);
tree index_cond_expr;
- if (STMT_VINFO_REDUC_IDX (stmt_info) == 2)
+ if (STMT_VINFO_REDUC_IDX (cond_info) == 2)
index_cond_expr = build3 (VEC_COND_EXPR, cr_index_vector_type,
ccompare, indx_before_incr, new_phi_tree);
else
@@ -4809,10 +4818,11 @@ vect_create_epilog_for_reduction (stmt_vec_info stmt_info,
be zero. */
/* Vector of {0, 0, 0,...}. */
- tree zero_vec = make_ssa_name (vectype);
- tree zero_vec_rhs = build_zero_cst (vectype);
- gimple *zero_vec_stmt = gimple_build_assign (zero_vec, zero_vec_rhs);
- gsi_insert_before (&exit_gsi, zero_vec_stmt, GSI_SAME_STMT);
+ tree zero_vec = build_zero_cst (vectype);
+
+ gimple_seq stmts = NULL;
+ new_phi_result = gimple_convert (&stmts, vectype, new_phi_result);
+ gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT);
/* Find maximum value from the vector of found indexes. */
tree max_index = make_ssa_name (index_scalar_type);
@@ -4880,7 +4890,7 @@ vect_create_epilog_for_reduction (stmt_vec_info stmt_info,
/* Convert the reduced value back to the result type and set as the
result. */
- gimple_seq stmts = NULL;
+ stmts = NULL;
new_temp = gimple_build (&stmts, VIEW_CONVERT_EXPR, scalar_type,
data_reduc);
gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT);