re PR tree-optimization/89618 (Inner loop won't vectorize unless dummy statement...
authorRichard Biener <rguenther@suse.de>
Thu, 7 Mar 2019 14:53:37 +0000 (14:53 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 7 Mar 2019 14:53:37 +0000 (14:53 +0000)
2019-04-07  Richard Biener  <rguenther@suse.de>

PR middle-end/89618
* cfgloopmanip.c (copy_loop_info): Copy forgotten fields.
* tree-inline.c (copy_loops): Simplify.

* gcc.target/i386/pr89618.c: New testcase.

From-SVN: r269458

gcc/ChangeLog
gcc/cfgloopmanip.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr89618.c [new file with mode: 0644]
gcc/tree-inline.c

index b7244461267a9e2e920a41dde09ae89513e253ae..b5a73871a21165900cc7f56ef962cc244adeb3b9 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89618
+       * cfgloopmanip.c (copy_loop_info): Copy forgotten fields.
+       * tree-inline.c (copy_loops): Simplify.
+
 2019-03-07  Martin Liska  <mliska@suse.cz>
 
        * dwarf2out.c (add_AT_vms_delta): Revert function removal.
index 17226b725f55dc53f226b25327f15de37c909d4a..7eb587aaf6157292c7c20e33560e6206c2a59fb1 100644 (file)
@@ -1015,10 +1015,15 @@ copy_loop_info (struct loop *loop, struct loop *target)
   target->any_estimate = loop->any_estimate;
   target->nb_iterations_estimate = loop->nb_iterations_estimate;
   target->estimate_state = loop->estimate_state;
+  target->safelen = loop->safelen;
   target->constraints = loop->constraints;
+  target->can_be_parallel = loop->can_be_parallel;
   target->warned_aggressive_loop_optimizations
     |= loop->warned_aggressive_loop_optimizations;
+  target->dont_vectorize = loop->dont_vectorize;
+  target->force_vectorize = loop->force_vectorize;
   target->in_oacc_kernels_region = loop->in_oacc_kernels_region;
+  target->unroll = loop->unroll;
 }
 
 /* Copies copy of LOOP as subloop of TARGET loop, placing newly
index 26f1716df9ad4b8b5e8575bb53844c9550160f34..d13a7db0bb81e1beb2d3365702d891c6f71b13c2 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89618
+       * gcc.target/i386/pr89618.c: New testcase.
+
 2019-03-07  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/89595
diff --git a/gcc/testsuite/gcc.target/i386/pr89618.c b/gcc/testsuite/gcc.target/i386/pr89618.c
new file mode 100644 (file)
index 0000000..11b2d28
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -mavx512f -fdump-tree-vect-details" } */
+
+void foo (int n, int *off, double *a)
+{
+  const int m = 32;
+
+  for (int j = 0; j < n/m; ++j)
+    {
+      int const start = j*m;
+      int const end = (j+1)*m;
+
+#pragma GCC ivdep
+      for (int i = start; i < end; ++i)
+       {
+         a[off[i]] = a[i] < 0 ? a[i] : 0;
+       }
+    }
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
index 9017da878b147c6edb3c91cb176a32a8fc063b75..d3e53d2cb38804f4e324c8816e6d6ee896b4ab70 100644 (file)
@@ -2666,23 +2666,15 @@ copy_loops (copy_body_data *id,
 
          /* Copy loop meta-data.  */
          copy_loop_info (src_loop, dest_loop);
+         if (dest_loop->unroll)
+           cfun->has_unroll = true;
+         if (dest_loop->force_vectorize)
+           cfun->has_force_vectorize_loops = true;
 
          /* Finally place it into the loop array and the loop tree.  */
          place_new_loop (cfun, dest_loop);
          flow_loop_tree_node_add (dest_parent, dest_loop);
 
-         dest_loop->safelen = src_loop->safelen;
-         if (src_loop->unroll)
-           {
-             dest_loop->unroll = src_loop->unroll;
-             cfun->has_unroll = true;
-           }
-         dest_loop->dont_vectorize = src_loop->dont_vectorize;
-         if (src_loop->force_vectorize)
-           {
-             dest_loop->force_vectorize = true;
-             cfun->has_force_vectorize_loops = true;
-           }
          if (src_loop->simduid)
            {
              dest_loop->simduid = remap_decl (src_loop->simduid, id);