re PR tree-optimization/66272 (wrong code at -O3 on x86_64-linux-gnu)
authorRichard Biener <rguenther@suse.de>
Wed, 27 May 2015 14:20:48 +0000 (14:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 27 May 2015 14:20:48 +0000 (14:20 +0000)
2015-05-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/66272
Revert parts of
2014-08-15  Richard Biener  <rguenther@suse.de>

PR tree-optimization/62031
* tree-data-ref.c (dr_analyze_indices): Do not set
DR_UNCONSTRAINED_BASE.
(dr_may_alias_p): All indirect accesses have to go the
formerly DR_UNCONSTRAINED_BASE path.
* tree-data-ref.h (struct indices): Remove
unconstrained_base member.
(DR_UNCONSTRAINED_BASE): Remove.

* gcc.dg/torture/pr66272.c: New testcase.

From-SVN: r223759

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr66272.c [new file with mode: 0644]
gcc/tree-data-ref.c
gcc/tree-data-ref.h

index 13422ed8ae90f323364695521f1fb2081b6f9247..762c058d54b38b6e7b9347189e4078069404a430 100644 (file)
@@ -1,3 +1,18 @@
+2015-05-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66272
+       Revert parts of
+       2014-08-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62031
+       * tree-data-ref.c (dr_analyze_indices): Do not set
+       DR_UNCONSTRAINED_BASE.
+       (dr_may_alias_p): All indirect accesses have to go the
+       formerly DR_UNCONSTRAINED_BASE path.
+       * tree-data-ref.h (struct indices): Remove
+       unconstrained_base member.
+       (DR_UNCONSTRAINED_BASE): Remove.
+
 2015-05-27  Aldy Hernandez  <aldyh@redhat.com>
 
        * dwarf2out.c: Remove block_map.
index 5b9be3fa2db87a75278ba1f4cd81eace6d3928e9..9afe448962196d4287fc1214221930a20a8fee90 100644 (file)
@@ -1,3 +1,12 @@
+2015-05-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66272
+       Revert parts of
+       2014-08-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62031
+       * gcc.dg/torture/pr66272.c: New testcase.
+
 2015-05-27  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/vect/slp-reduc-7.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr66272.c b/gcc/testsuite/gcc.dg/torture/pr66272.c
new file mode 100644 (file)
index 0000000..6f0148a
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+struct S
+{
+  int f0;
+  int f1;
+};
+
+int b;
+
+int main ()
+{
+  struct S a[2] = { 0 };
+  struct S d = { 0, 1 };
+  for (b = 0; b < 2; b++)
+    {
+      a[b] = d;
+      d = a[0];
+    }
+  if (d.f1 != 1)
+    __builtin_abort ();
+  return 0;
+}
index 505d63b00832d4aed0e0a6782a067f2596abf956..368d3dfc72a1d9d4a56c5ab8f0a5d2b6ac8460cb 100644 (file)
@@ -1036,6 +1036,7 @@ dr_analyze_indices (struct data_reference *dr, loop_p nest, loop_p loop)
                                 base, memoff);
          MR_DEPENDENCE_CLIQUE (ref) = MR_DEPENDENCE_CLIQUE (old);
          MR_DEPENDENCE_BASE (ref) = MR_DEPENDENCE_BASE (old);
+         DR_UNCONSTRAINED_BASE (dr) = true;
          access_fns.safe_push (access_fn);
        }
     }
@@ -1453,7 +1454,8 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b,
      offset/overlap based analysis but have to rely on points-to
      information only.  */
   if (TREE_CODE (addr_a) == MEM_REF
-      && TREE_CODE (TREE_OPERAND (addr_a, 0)) == SSA_NAME)
+      && (DR_UNCONSTRAINED_BASE (a)
+         || TREE_CODE (TREE_OPERAND (addr_a, 0)) == SSA_NAME))
     {
       /* For true dependences we can apply TBAA.  */
       if (flag_strict_aliasing
@@ -1469,7 +1471,8 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b,
                                       build_fold_addr_expr (addr_b));
     }
   else if (TREE_CODE (addr_b) == MEM_REF
-          && TREE_CODE (TREE_OPERAND (addr_b, 0)) == SSA_NAME)
+          && (DR_UNCONSTRAINED_BASE (b)
+              || TREE_CODE (TREE_OPERAND (addr_b, 0)) == SSA_NAME))
     {
       /* For true dependences we can apply TBAA.  */
       if (flag_strict_aliasing
index edb3b562b8a255790c67c18d9b0b623299773532..9d8e6992f800319f649e60e8298f043cf3d6066e 100644 (file)
@@ -81,6 +81,10 @@ struct indices
 
   /* A list of chrecs.  Access functions of the indices.  */
   vec<tree> access_fns;
+
+  /* Whether BASE_OBJECT is an access representing the whole object
+     or whether the access could not be constrained.  */
+  bool unconstrained_base;
 };
 
 struct dr_alias
@@ -129,6 +133,7 @@ struct data_reference
 #define DR_STMT(DR)                (DR)->stmt
 #define DR_REF(DR)                 (DR)->ref
 #define DR_BASE_OBJECT(DR)         (DR)->indices.base_object
+#define DR_UNCONSTRAINED_BASE(DR)  (DR)->indices.unconstrained_base
 #define DR_ACCESS_FNS(DR)         (DR)->indices.access_fns
 #define DR_ACCESS_FN(DR, I)        DR_ACCESS_FNS (DR)[I]
 #define DR_NUM_DIMENSIONS(DR)      DR_ACCESS_FNS (DR).length ()