re PR tree-optimization/33834 (ICE in vect_get_vec_def_for_operand, at tree-vect...
authorDorit Nuzman <dorit@gcc.gnu.org>
Tue, 23 Oct 2007 03:24:06 +0000 (03:24 +0000)
committerDorit Nuzman <dorit@gcc.gnu.org>
Tue, 23 Oct 2007 03:24:06 +0000 (03:24 +0000)
        PR tree-optimization/33834
        PR tree-optimization/33835
        * tree-vect-analyze.c (vect_analyze_operations): RELEVANT and LIVE stmts
        need to be checked for success seperately.
        * tree-vect-transform.c (vectorizable_call, vectorizable_conversion):
        Remove the check that stmt is not LIVE.
        (vectorizable_assignment, vectorizable_induction): Likewise.
        (vectorizable_operation, vectorizable_type_demotion): Likewise.
        (vectorizable_type_promotion, vectorizable_load, vectorizable_store):
        Likewise.
        (vectorizable_live_operation): Check that op is not NULL.

From-SVN: r129571

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/vect/pr33834_1.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/vect/pr33834_2.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/vect/pr33835.cc [new file with mode: 0644]
gcc/tree-vect-analyze.c
gcc/tree-vect-transform.c

index 419c308355e5f59672d8ec5d89827b3426d943fa..390ed0db2e643b57f6e2ecc6834766c718fa8ff7 100644 (file)
@@ -1,3 +1,17 @@
+2007-10-22  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/33834
+       PR tree-optimization/33835
+       * tree-vect-analyze.c (vect_analyze_operations): RELEVANT and LIVE stmts
+       need to be checked for success seperately.
+       * tree-vect-transform.c (vectorizable_call, vectorizable_conversion):
+       Remove the check that stmt is not LIVE.
+       (vectorizable_assignment, vectorizable_induction): Likewise.
+       (vectorizable_operation, vectorizable_type_demotion): Likewise.
+       (vectorizable_type_promotion, vectorizable_load, vectorizable_store):
+       Likewise.
+       (vectorizable_live_operation): Check that op is not NULL. 
+
 2007-10-22  Janis Johnson  <janis187@us.ibm.com>
 
        * doc/invoke.texi (Optimization Options): In the summary, show
index 01f6cd5b59af1481d0413eb2d44cddee12e4c715..ecc4e8010a00101ccbe51047a508d72e62a3d1cd 100644 (file)
@@ -1,3 +1,12 @@
+2007-10-22  Martin Michlmayr <tbm@cyrius.com>  
+           Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/33834
+       PR tree-optimization/33835
+       * g++.dg/vect/pr33834_1.cc: New test.
+       * g++.dg/vect/pr33834_2.cc: New test.
+       * g++.dg/vect/pr33835.cc: New test.
+
 2007-10-22  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/pr33644.c: New test.
diff --git a/gcc/testsuite/g++.dg/vect/pr33834_1.cc b/gcc/testsuite/g++.dg/vect/pr33834_1.cc
new file mode 100644 (file)
index 0000000..715ff0d
--- /dev/null
@@ -0,0 +1,50 @@
+/* { dg-do compile } */
+
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+
+extern double cos (double x);
+extern double sin (double x);
+
+class bend_class
+{
+  double *s_A;
+public:
+  void set_s_A (double s_A0)
+  {
+    s_A[0] = s_A0;
+  }
+};
+class bend_set
+{
+  bend_class *bend_array;
+public:
+  void set_s_A (int index, double s_A0)
+  {
+    bend_array[index].set_s_A (s_A0);
+  }
+  void compute_s (void)
+  {
+    int i, j;
+    double val;
+    double tmp[3];
+    for (i = 0; i < 5; ++i)
+    {
+      val = i;
+      for (j = 0; j < 2; ++j)
+        tmp[j] = cos (val);
+      set_s_A (i, tmp[0]);
+      tmp[j] = cos (val) / sin (val);
+    }
+  }
+};
+class internals
+{
+  bend_set bend;
+  void compute_s (void);
+};
+void
+internals::compute_s (void)
+{
+  bend.compute_s ();
+}
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/g++.dg/vect/pr33834_2.cc b/gcc/testsuite/g++.dg/vect/pr33834_2.cc
new file mode 100644 (file)
index 0000000..1230ca3
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftree-vectorize" } */
+
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+
+extern int sscanf (__const char *__restrict __s,
+                  __const char *__restrict __format, ...);
+unsigned char got_elevation_pattern;
+struct site
+{
+  float antenna_pattern[361][1001];
+}
+LR;
+void
+LoadPAT (char *filename)
+{
+  int x, y;
+  char string[255];
+  float elevation, amplitude, elevation_pattern[361][1001];
+  for (x = 0; filename[x] != '.' ; x++)
+    sscanf (string, "%f %f", &elevation, &amplitude);
+  for (y = 0; y <= 1000; y++)
+  {
+    if (got_elevation_pattern)
+      elevation = elevation_pattern[x][y];
+    else
+      elevation = 1.0;
+    LR.antenna_pattern[x][y] = elevation;
+  }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/g++.dg/vect/pr33835.cc b/gcc/testsuite/g++.dg/vect/pr33835.cc
new file mode 100644 (file)
index 0000000..1ab4c7e
--- /dev/null
@@ -0,0 +1,50 @@
+/* { dg-do compile } */
+
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+
+extern double cos (double x);
+
+class bend_class
+{
+  double *s_A;
+public:
+  void set_s_A (double s_A0)
+  {
+    s_A[0] = s_A0;
+  }
+};
+class bend_set
+{
+  bend_class *bend_array;
+public:
+  void set_s_A (int index, double s_A0)
+  {
+    bend_array[index].set_s_A (s_A0);
+  }
+  void compute_s (void)
+  {
+    int i, j;
+    double val;
+    double tmp[3];
+    for (i = 0; i < 5; ++i)
+    {
+      val = i;
+      for (j = 0; j < 2; ++j)
+        tmp[j] = cos (val);
+      set_s_A (i, tmp[0]);
+      tmp[j] = cos (val);
+    }
+  }
+};
+class internals
+{
+  bend_set bend;
+  void compute_s (void);
+};
+void
+internals::compute_s (void)
+{
+  bend.compute_s ();
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 04257afabc49f12b716ab6c6beacaab5fcb06cf3..b91fbc05bb97b1ad9adfe2e712e0aa6918f641fa 100644 (file)
@@ -482,7 +482,10 @@ vect_analyze_operations (loop_vec_info loop_vinfo)
              need_to_vectorize = true;
            }
 
-         ok = (vectorizable_type_promotion (stmt, NULL, NULL)
+         ok = true;
+         if (STMT_VINFO_RELEVANT_P (stmt_info)
+             || STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
+           ok = (vectorizable_type_promotion (stmt, NULL, NULL)
                || vectorizable_type_demotion (stmt, NULL, NULL)
                || vectorizable_conversion (stmt, NULL, NULL, NULL)
                || vectorizable_operation (stmt, NULL, NULL, NULL)
@@ -493,17 +496,29 @@ vect_analyze_operations (loop_vec_info loop_vinfo)
                || vectorizable_condition (stmt, NULL, NULL)
                || vectorizable_reduction (stmt, NULL, NULL));
 
+         if (!ok)
+           {
+             if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+               {
+                 fprintf (vect_dump, "not vectorized: relevant stmt not ");
+                 fprintf (vect_dump, "supported: ");
+                 print_generic_expr (vect_dump, stmt, TDF_SLIM);
+               }
+             return false;
+           }
+
          /* Stmts that are (also) "live" (i.e. - that are used out of the loop)
             need extra handling, except for vectorizable reductions.  */
          if (STMT_VINFO_LIVE_P (stmt_info)
              && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type) 
-           ok |= vectorizable_live_operation (stmt, NULL, NULL);
+           ok = vectorizable_live_operation (stmt, NULL, NULL);
 
          if (!ok)
            {
              if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
                {
-                 fprintf (vect_dump, "not vectorized: stmt not supported: ");
+                 fprintf (vect_dump, "not vectorized: live stmt not ");
+                 fprintf (vect_dump, "supported: ");
                  print_generic_expr (vect_dump, stmt, TDF_SLIM);
                }
              return false;
@@ -3250,7 +3265,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo)
             inner-loop: *(BASE+INIT). (The first location is actually
             BASE+INIT+OFFSET, but we add OFFSET separately later.  */
          tree inner_base = build_fold_indirect_ref 
-                               (fold_build2 (PLUS_EXPR, TREE_TYPE (base), base, init));
+                               (fold_build2 (PLUS_EXPR, 
+                                             TREE_TYPE (base), base, init));
 
          if (vect_print_dump_info (REPORT_DETAILS))
            {
index c718e0742127284762526bcc17542349d737cedf..0578239083a322814482e438bf54c71b96df7c66 100644 (file)
@@ -2961,14 +2961,6 @@ vectorizable_call (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
   if (STMT_SLP_TYPE (stmt_info))
     return false;
 
-  /* FORNOW: not yet supported.  */
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is STMT a vectorizable call?   */
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
@@ -3307,14 +3299,6 @@ vectorizable_conversion (tree stmt, block_stmt_iterator *bsi,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      /* FORNOW: not yet supported.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-       fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
 
@@ -3585,14 +3569,6 @@ vectorizable_assignment (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  /* FORNOW: not yet supported.  */
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is vectorizable assignment?  */
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
@@ -3702,14 +3678,6 @@ vectorizable_induction (tree phi, block_stmt_iterator *bsi ATTRIBUTE_UNUSED,
 
   gcc_assert (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def);
 
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      /* FORNOW: not yet supported.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   if (TREE_CODE (phi) != PHI_NODE)
     return false;
 
@@ -3791,14 +3759,6 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  /* FORNOW: not yet supported.  */
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is STMT a vectorizable binary/unary operation?   */
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
@@ -4088,14 +4048,6 @@ vectorizable_type_demotion (tree stmt, block_stmt_iterator *bsi,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  /* FORNOW: not yet supported.  */
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is STMT a vectorizable type-demotion operation?  */
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
@@ -4249,14 +4201,6 @@ vectorizable_type_promotion (tree stmt, block_stmt_iterator *bsi,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  /* FORNOW: not yet supported.  */
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is STMT a vectorizable type-promotion operation?  */
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
@@ -4629,13 +4573,6 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is vectorizable store? */
 
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
@@ -5458,14 +5395,6 @@ vectorizable_load (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_loop_def)
     return false;
 
-  /* FORNOW: not yet supported.  */
-  if (STMT_VINFO_LIVE_P (stmt_info))
-    {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
-      return false;
-    }
-
   /* Is vectorizable load? */
   if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
     return false;
@@ -5893,7 +5822,7 @@ vectorizable_live_operation (tree stmt,
   for (i = 0; i < op_type; i++)
     {
       op = TREE_OPERAND (operation, i);
-      if (!vect_is_simple_use (op, loop_vinfo, &def_stmt, &def, &dt))
+      if (op && !vect_is_simple_use (op, loop_vinfo, &def_stmt, &def, &dt))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             fprintf (vect_dump, "use not simple.");