]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/58921 (ICE with segfault on valid code at -O3 on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Tue, 14 Jan 2014 09:04:50 +0000 (09:04 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 14 Jan 2014 09:04:50 +0000 (09:04 +0000)
2014-01-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/58921
PR tree-optimization/59006
* tree-vect-loop-manip.c (vect_loop_versioning): Remove code
hoisting invariant stmts.
* tree-vect-stmts.c (vectorizable_load): Insert the splat of
invariant loads on the preheader edge if possible.

* gcc.dg/torture/pr58921.c: New testcase.
* gcc.dg/torture/pr59006.c: Likewise.
* gcc.dg/vect/pr58508.c: XFAIL no longer handled cases.

From-SVN: r206599

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr58921.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr59006.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr58508.c
gcc/tree-vect-loop-manip.c
gcc/tree-vect-stmts.c

index 3a832d0e898c1e423e00a9f621076525009676ed..d9d19491f4f7684d9825558b83b54945f920e3f0 100644 (file)
@@ -1,3 +1,12 @@
+2014-01-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58921
+       PR tree-optimization/59006
+       * tree-vect-loop-manip.c (vect_loop_versioning): Remove code
+       hoisting invariant stmts.
+       * tree-vect-stmts.c (vectorizable_load): Insert the splat of
+       invariant loads on the preheader edge if possible.
+
 2014-01-14  Joey Ye  <joey.ye@arm.com>
 
        * doc/plugin.texi (Building GCC plugins): Update to C++.
index 4c59e37a4ccc3787bafc3aa43c0c945a5961731c..8a3b56d3eb2b076d6a0a6d0b9af7aa41ccd0d672 100644 (file)
@@ -1,3 +1,11 @@
+2014-01-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58921
+       PR tree-optimization/59006
+       * gcc.dg/torture/pr58921.c: New testcase.
+       * gcc.dg/torture/pr59006.c: Likewise.
+       * gcc.dg/vect/pr58508.c: XFAIL no longer handled cases.
+
 2014-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR testsuite/59494
diff --git a/gcc/testsuite/gcc.dg/torture/pr58921.c b/gcc/testsuite/gcc.dg/torture/pr58921.c
new file mode 100644 (file)
index 0000000..7d7c985
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+int a[7];
+int b;
+
+void
+fn1 ()
+{
+  for (; b; b++)
+    a[b] = ((a[b] <= 0) == (a[0] != 0));
+}
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr59006.c b/gcc/testsuite/gcc.dg/torture/pr59006.c
new file mode 100644 (file)
index 0000000..34de83d
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+int a[8], b;
+void fn1(void)
+{
+  int c;
+  for (; b; b++)
+    {
+      int d = a[b];
+      c = a[0] ? d : 0;
+      a[b] = c;
+    }
+}
index c1ca3347c1462e8567229cb1b68434316a35c8ea..c25da416baf1ec7cc27b750ff4146e8db2662b4a 100644 (file)
@@ -66,5 +66,6 @@ void test5 (int* a, int* b)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "hoist" 8 "vect" { xfail vect_no_align } } } */
+/* { dg-final { scan-tree-dump-times "hoist" 8 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "hoist" 3 "vect" { xfail vect_no_align } } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index f68626171d147db29722f356cbb768574445be00..77d945e6a505304ac8d4a1a7c7fb40f6b7519b31 100644 (file)
@@ -2435,73 +2435,6 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
        }
     }
 
-
-  /* Extract load statements on memrefs with zero-stride accesses.  */
-
-  if (LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo))
-    {
-      /* In the loop body, we iterate each statement to check if it is a load.
-        Then we check the DR_STEP of the data reference.  If DR_STEP is zero,
-        then we will hoist the load statement to the loop preheader.  */
-
-      basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
-      int nbbs = loop->num_nodes;
-
-      for (int i = 0; i < nbbs; ++i)
-       {
-         for (gimple_stmt_iterator si = gsi_start_bb (bbs[i]);
-              !gsi_end_p (si);)
-           {
-             gimple stmt = gsi_stmt (si);
-             stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-             struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
-
-             if (is_gimple_assign (stmt)
-                 && (!dr
-                     || (DR_IS_READ (dr) && integer_zerop (DR_STEP (dr)))))
-               {
-                 bool hoist = true;
-                 ssa_op_iter iter;
-                 tree var;
-
-                 /* We hoist a statement if all SSA uses in it are defined
-                    outside of the loop.  */
-                 FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_USE)
-                   {
-                     gimple def = SSA_NAME_DEF_STMT (var);
-                     if (!gimple_nop_p (def)
-                         && flow_bb_inside_loop_p (loop, gimple_bb (def)))
-                       {
-                         hoist = false;
-                         break;
-                       }
-                   }
-
-                 if (hoist)
-                   {
-                     if (dr)
-                       gimple_set_vuse (stmt, NULL);
-
-                     gsi_remove (&si, false);
-                     gsi_insert_on_edge_immediate (loop_preheader_edge (loop),
-                                                   stmt);
-
-                     if (dump_enabled_p ())
-                       {
-                         dump_printf_loc
-                             (MSG_NOTE, vect_location,
-                              "hoisting out of the vectorized loop: ");
-                         dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
-                         dump_printf (MSG_NOTE, "\n");
-                       }
-                     continue;
-                   }
-               }
-             gsi_next (&si);
-           }
-       }
-    }
-
   /* End loop-exit-fixes after versioning.  */
 
   if (cond_expr_stmt_list)
index cdeb4578abe0f5b5108848030f826af985e5d23b..acdaa2db8afe61c0e10410a9fb2ad4f65911e637 100644 (file)
@@ -6380,12 +6380,39 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
              /* 4. Handle invariant-load.  */
              if (inv_p && !bb_vinfo)
                {
-                 gimple_stmt_iterator gsi2 = *gsi;
                  gcc_assert (!grouped_load);
-                 gsi_next (&gsi2);
-                 new_temp = vect_init_vector (stmt, scalar_dest,
-                                              vectype, &gsi2);
+                 /* If we have versioned for aliasing then we are sure
+                    this is a loop invariant load and thus we can insert
+                    it on the preheader edge.  */
+                 if (LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo))
+                   {
+                     if (dump_enabled_p ())
+                       {
+                         dump_printf_loc (MSG_NOTE, vect_location,
+                                          "hoisting out of the vectorized "
+                                          "loop: ");
+                         dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
+                         dump_printf (MSG_NOTE, "\n");
+                       }
+                     tree tem = copy_ssa_name (scalar_dest, NULL);
+                     gsi_insert_on_edge_immediate
+                       (loop_preheader_edge (loop),
+                        gimple_build_assign (tem,
+                                             unshare_expr
+                                               (gimple_assign_rhs1 (stmt))));
+                     new_temp = vect_init_vector (stmt, tem, vectype, NULL);
+                   }
+                 else
+                   {
+                     gimple_stmt_iterator gsi2 = *gsi;
+                     gsi_next (&gsi2);
+                     new_temp = vect_init_vector (stmt, scalar_dest,
+                                                  vectype, &gsi2);
+                   }
                  new_stmt = SSA_NAME_DEF_STMT (new_temp);
+                 set_vinfo_for_stmt (new_stmt,
+                                     new_stmt_vec_info (new_stmt, loop_vinfo,
+                                                        bb_vinfo));
                }
 
              if (negative)