aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-12-31 15:32:06 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-12-31 15:32:06 +0000
commitdc176c3ccd6a8cd3f809f3c1549ad00674061eb5 (patch)
treee3031a3fa6224b66dbc492230ee7996572dd0cbc /gcc
parent2c8297996a7ab3496c5d2f798cdbe4cab749468e (diff)
downloadgcc-dc176c3ccd6a8cd3f809f3c1549ad00674061eb5.zip
gcc-dc176c3ccd6a8cd3f809f3c1549ad00674061eb5.tar.gz
gcc-dc176c3ccd6a8cd3f809f3c1549ad00674061eb5.tar.bz2
Fix EXTRACT_LAST_REDUCTION segfault
This code: /* Make sure we don't accidentally use the old condition. */ cond_expr = NULL_TREE; was misplaced, since it triggered even when we needed to force the original unmodified cond_expr into a mask temporary and then invert it. 2019-12-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-stmts.c (vectorizable_condition): Only nullify cond_expr if we've created a new condition. Don't nullify it if we've decided to keep it and then invert the result. gcc/testsuite/ * gcc.dg/vect/vect-cond-reduc-6.c: New test. From-SVN: r279804
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-cond-reduc-6.c10
-rw-r--r--gcc/tree-vect-stmts.c8
4 files changed, 25 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a75b901..9f5782f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2020-12-31 Richard Sandiford <richard.sandiford@arm.com>
+ * tree-vect-stmts.c (vectorizable_condition): Only nullify cond_expr
+ if we've created a new condition. Don't nullify it if we've decided
+ to keep it and then invert the result.
+
+2020-12-31 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-vect-loop-manip.c (create_lcssa_for_virtual_phi): Return
the incoming virtual operand definition.
(vect_do_peeling): When vectorizing an epilogue loop, handle the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 097c61d..b3211aa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2020-12-31 Richard Sandiford <richard.sandiford@arm.com>
+ * gcc.dg/vect/vect-cond-reduc-6.c: New test.
+
+2020-12-31 Richard Sandiford <richard.sandiford@arm.com>
+
* gcc.dg/vect/vect-epilogues-2.c: New test.
2019-12-30 Olivier Hainque <hainque@adacore.com>
diff --git a/gcc/testsuite/gcc.dg/vect/vect-cond-reduc-6.c b/gcc/testsuite/gcc.dg/vect/vect-cond-reduc-6.c
new file mode 100644
index 0000000..f1a2209
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-cond-reduc-6.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+int
+f (int *y)
+{
+ int res = 0;
+ for (int i = 0; i < 100; ++i)
+ res = (y[i] & 1) == 0 && (y[i] < 10) ? res : 1;
+ return res;
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index d446808..0ce9793 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -10033,10 +10033,12 @@ vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
if (new_code == ERROR_MARK)
must_invert_cmp_result = true;
else
- cond_code = new_code;
+ {
+ cond_code = new_code;
+ /* Make sure we don't accidentally use the old condition. */
+ cond_expr = NULL_TREE;
+ }
}
- /* Make sure we don't accidentally use the old condition. */
- cond_expr = NULL_TREE;
std::swap (then_clause, else_clause);
}