]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/46969 (-fcompare-debug failure with -O -ftree-vectorize ...
authorJakub Jelinek <jakub@redhat.com>
Sat, 18 Dec 2010 21:07:12 +0000 (22:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 18 Dec 2010 21:07:12 +0000 (22:07 +0100)
PR tree-optimization/46969
* tree-parloops.c (struct reduction_info): Add reduc_version.
(reduction_info_hash): Return reduc_version field.
(reduction_phi): Set reduc_version to gimple_uid (phi).
(build_new_reduction): Set reduc_version to SSA_NAME_VERSION of
phi result.
(set_reduc_phi_uids): New function.
(gather_scalar_reductions): Call it at the end through htab_traverse.

* gcc.dg/autopar/pr46969.c: New test.

From-SVN: r168034

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/autopar/pr46969.c [new file with mode: 0644]
gcc/tree-parloops.c

index cf8d786f6127f7408b26560591f5f9368ee18e46..0450bfd37e6cc32552d5e5c2ba44929f1d522662 100644 (file)
@@ -1,3 +1,14 @@
+2010-12-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/46969
+       * tree-parloops.c (struct reduction_info): Add reduc_version.
+       (reduction_info_hash): Return reduc_version field.
+       (reduction_phi): Set reduc_version to gimple_uid (phi).
+       (build_new_reduction): Set reduc_version to SSA_NAME_VERSION of
+       phi result.
+       (set_reduc_phi_uids): New function.
+       (gather_scalar_reductions): Call it at the end through htab_traverse.
+
 2010-12-18  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * c-parser.c (c_parser_objc_try_catch_finally_statement): Call
index 594bf0635ed8fac7ad7edcac549b5f8671380102..d3bb0def1ce7073c5b3304c742e80abddd237e15 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/46969
+       * gcc.dg/autopar/pr46969.c: New test.
+
 2010-12-18  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc.dg/fobjc-exceptions-1.m: Updated.
diff --git a/gcc/testsuite/gcc.dg/autopar/pr46969.c b/gcc/testsuite/gcc.dg/autopar/pr46969.c
new file mode 100644 (file)
index 0000000..807ce4f
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR tree-optimization/46969 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftree-parallelize-loops=2 -fcompare-debug" } */
+
+extern void abort (void);
+#define F(name) \
+int                                                            \
+name (unsigned char *x)                                                \
+{                                                              \
+  int i;                                                       \
+  unsigned int c, d, e;                                                \
+  if (x != 0)                                                  \
+    {                                                          \
+      for (i = 0, d = 0, e = 0xFFFFFFFF;                       \
+          i < 64;                                              \
+          i += (int) sizeof(unsigned int))                     \
+        {                                                      \
+          c = *((unsigned int *)(&x[i]));                      \
+          d = d | c;                                           \
+          e = e & c;                                           \
+        }                                                      \
+      if (!((d == e) && ((d >> 8) == (e & 0x00FFFFFF))))       \
+        abort ();                                              \
+    }                                                          \
+  return 0;                                                    \
+}
+F (foo0) F (foo1)
+F (foo2) F (foo3)
+F (foo4) F (foo5)
+F (foo6) F (foo7)
+F (foo8) F (foo9)
index 25ef2f29454f72b8708c99c356b2a90aacb2926b..ea1911a81fa421bcdc4e93e01ddd0b67a6eeed07 100644 (file)
@@ -168,6 +168,8 @@ struct reduction_info
   gimple reduc_stmt;           /* reduction statement.  */
   gimple reduc_phi;            /* The phi node defining the reduction.  */
   enum tree_code reduction_code;/* code for the reduction operation.  */
+  unsigned reduc_version;      /* SSA_NAME_VERSION of original reduc_phi
+                                  result.  */
   gimple keep_res;             /* The PHI_RESULT of this phi is the resulting value
                                   of the reduction variable when existing the loop. */
   tree initial_value;          /* The initial value of the reduction var before entering the loop.  */
@@ -195,7 +197,7 @@ reduction_info_hash (const void *aa)
 {
   const struct reduction_info *a = (const struct reduction_info *) aa;
 
-  return htab_hash_pointer (a->reduc_phi);
+  return a->reduc_version;
 }
 
 static struct reduction_info *
@@ -207,6 +209,7 @@ reduction_phi (htab_t reduction_list, gimple phi)
     return NULL;
 
   tmpred.reduc_phi = phi;
+  tmpred.reduc_version = gimple_uid (phi);
   red = (struct reduction_info *) htab_find (reduction_list, &tmpred);
 
   return red;
@@ -1774,11 +1777,22 @@ build_new_reduction (htab_t reduction_list, gimple reduc_stmt, gimple phi)
 
   new_reduction->reduc_stmt = reduc_stmt;
   new_reduction->reduc_phi = phi;
+  new_reduction->reduc_version = SSA_NAME_VERSION (gimple_phi_result (phi));
   new_reduction->reduction_code = gimple_assign_rhs_code (reduc_stmt);
   slot = htab_find_slot (reduction_list, new_reduction, INSERT);
   *slot = new_reduction;
 }
 
+/* Callback for htab_traverse.  Sets gimple_uid of reduc_phi stmts.  */
+
+static int
+set_reduc_phi_uids (void **slot, void *data ATTRIBUTE_UNUSED)
+{
+  struct reduction_info *const red = (struct reduction_info *) *slot;
+  gimple_set_uid (red->reduc_phi, red->reduc_version);
+  return 1;
+}
+
 /* Detect all reductions in the LOOP, insert them into REDUCTION_LIST.  */
 
 static void
@@ -1810,7 +1824,12 @@ gather_scalar_reductions (loop_p loop, htab_t reduction_list)
               build_new_reduction (reduction_list, reduc_stmt, phi);
         }
     }
-    destroy_loop_vec_info (simple_loop_info, true);
+  destroy_loop_vec_info (simple_loop_info, true);
+
+  /* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form
+     and destroy_loop_vec_info, we can set gimple_uid of reduc_phi stmts
+     only now.  */
+  htab_traverse (reduction_list, set_reduc_phi_uids, NULL);
 }
 
 /* Try to initialize NITER for code generation part.  */