Restore flow_bb_inside_loop_p tests (PR 86858)
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 9 Aug 2018 14:45:02 +0000 (14:45 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 9 Aug 2018 14:45:02 +0000 (14:45 +0000)
The series to remove vinfo_for_stmt also removed tests of
flow_bb_inside_loop_p if the call was simply testing whether the
statement was in the vectorisation region.  I'd tried to keep calls
that were testing whether the statement was in a particular loop
(inner or outer), but messed up in vect_is_simple_reduction and
removed calls that were actually needed.  This patch restores them.

I double-checked the other removed calls and I think these are
the only ones affected.

2018-08-08  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR tree-optimization/86858
* tree-vect-loop.c (vect_is_simple_reduction): Restore
flow_bb_inside_loop_p calls.

gcc/testsuite/
PR tree-optimization/86858
* gcc.dg/vect/pr86858.c: New test.

From-SVN: r263448

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr86858.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 3e5f849e252a5edc6f997c601e4db78a8c90e695..3f8f9676f96d8940aeedd6257612a55fe52a51b4 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-09  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/86858
+       * tree-vect-loop.c (vect_is_simple_reduction): Restore
+       flow_bb_inside_loop_p calls.
+
 2018-08-09  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/86871
index 1edcf1eb7f791e9cf70456b65390e65dde2ec9a8..b59b4bbd3b1c1faac25ab4e04ccdc6539e4bc6a0 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-09  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/86858
+       * gcc.dg/vect/pr86858.c: New test.
+
 2018-08-09  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/86871
diff --git a/gcc/testsuite/gcc.dg/vect/pr86858.c b/gcc/testsuite/gcc.dg/vect/pr86858.c
new file mode 100644 (file)
index 0000000..6c3c6ec
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+int a, b, c, d;
+char e(char f, char g) { return f + g; }
+void h() {
+  for (; c; ++c) {
+    d = 0;
+    for (; d != 8; d = e(d, 3)) {
+      a = b && a;
+      b = c;
+    }
+  }
+}
index 92c01a21345762c7d98c64c5c75b338f747e9dab..0669f62c960054e67ad3b057729bdbd9fa79eb87 100644 (file)
@@ -2922,7 +2922,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info,
     }
 
   stmt_vec_info def_stmt_info = loop_info->lookup_def (loop_arg);
-  if (!def_stmt_info)
+  if (!def_stmt_info
+      || !flow_bb_inside_loop_p (loop, gimple_bb (def_stmt_info->stmt)))
     return NULL;
 
   if (gassign *def_stmt = dyn_cast <gassign *> (def_stmt_info->stmt))
@@ -3161,6 +3162,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info,
       && def2_info->stmt == phi
       && (code == COND_EXPR
          || !def1_info
+         || !flow_bb_inside_loop_p (loop, gimple_bb (def1_info->stmt))
          || vect_valid_reduction_input_p (def1_info)))
     {
       if (dump_enabled_p ())
@@ -3172,6 +3174,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info,
       && def1_info->stmt == phi
       && (code == COND_EXPR
          || !def2_info
+         || !flow_bb_inside_loop_p (loop, gimple_bb (def2_info->stmt))
          || vect_valid_reduction_input_p (def2_info)))
     {
       if (! nested_in_vect_loop && orig_code != MINUS_EXPR)