aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-15 13:52:09 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-11-15 13:52:09 +0000
commitb9f71c51cd578c6ab6ad2986edb80ba48aa477bc (patch)
treecf974b1e2f625191918c751588797b77128c1090
parentb6d53324092ee2b15c4a34fb55f2556863223d86 (diff)
downloadgcc-b9f71c51cd578c6ab6ad2986edb80ba48aa477bc.zip
gcc-b9f71c51cd578c6ab6ad2986edb80ba48aa477bc.tar.gz
gcc-b9f71c51cd578c6ab6ad2986edb80ba48aa477bc.tar.bz2
re PR tree-optimization/92512 (ICE in gimple_op, at gimple.h:2436)
2019-11-15 Richard Biener <rguenther@suse.de> PR tree-optimization/92512 * tree-vect-loop.c (check_reduction_path): Fix operand index computability check. Add check for second use in COND_EXPRs. * gcc.dg/torture/pr92512.c: New testcase. From-SVN: r278293
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr92512.c17
-rw-r--r--gcc/tree-vect-loop.c21
4 files changed, 45 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c2d3355..22fe571 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-15 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92512
+ * tree-vect-loop.c (check_reduction_path): Fix operand index
+ computability check. Add check for second use in COND_EXPRs.
+
2019-11-15 Richard Sandiford <richard.sandiford@arm.com>
PR target/92515
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4377c4c..82f559b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2019-11-15 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/92512
+ * gcc.dg/torture/pr92512.c: New testcase.
+
+2019-11-15 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/92324
* gcc.dg/vect/pr92324-4.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr92512.c b/gcc/testsuite/gcc.dg/torture/pr92512.c
new file mode 100644
index 0000000..2d873ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr92512.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+long int
+nl (long int fy, int k3, int zr)
+{
+ while (k3 < 1)
+ {
+ if (zr == 0)
+ fy = 0;
+
+ fy *= fy < zr;
+ ++k3;
+ }
+
+ return fy;
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 389ef17..e6ba91c 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2813,9 +2813,11 @@ pop:
/* The following make sure we can compute the operand index
easily plus it mostly disallows chaining via COND_EXPR condition
operands. */
- || (gimple_assign_rhs1 (use_stmt) != op
- && gimple_assign_rhs2 (use_stmt) != op
- && gimple_assign_rhs3 (use_stmt) != op))
+ || (gimple_assign_rhs1_ptr (use_stmt) != path[i].second->use
+ && (gimple_num_ops (use_stmt) <= 2
+ || gimple_assign_rhs2_ptr (use_stmt) != path[i].second->use)
+ && (gimple_num_ops (use_stmt) <= 3
+ || gimple_assign_rhs3_ptr (use_stmt) != path[i].second->use)))
{
fail = true;
break;
@@ -2828,7 +2830,18 @@ pop:
FOR_EACH_IMM_USE_STMT (op_use_stmt, imm_iter, op)
if (!is_gimple_debug (op_use_stmt)
&& flow_bb_inside_loop_p (loop, gimple_bb (op_use_stmt)))
- cnt++;
+ {
+ /* We want to allow x + x but not x < 1 ? x : 2. */
+ if (is_gimple_assign (op_use_stmt)
+ && gimple_assign_rhs_code (op_use_stmt) == COND_EXPR)
+ {
+ use_operand_p use_p;
+ FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+ cnt++;
+ }
+ else
+ cnt++;
+ }
if (cnt != 1)
{
fail = true;