]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2015-01-15 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Jan 2015 08:41:08 +0000 (08:41 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Jan 2015 08:41:08 +0000 (08:41 +0000)
PR middle-end/64365
* tree-data-ref.c (dr_analyze_indices): Make sure that accesses
for MEM_REF access functions with the same base can never partially
overlap.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219634 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 701c6c6734af139d452952a71730dc943e9f8d5e..2ab8dde144d9c549048e3faf0af80630b5e61d0c 100644 (file)
@@ -1,3 +1,10 @@
+2015-01-15  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64365
+       * tree-data-ref.c (dr_analyze_indices): Make sure that accesses
+       for MEM_REF access functions with the same base can never partially
+       overlap.
+
 2015-01-14  Marcos Diaz <marcos.diaz@tallertechnologies.com>
 
        * common.opt: New option -fstack-protector-explicit.
index 1c53160960f02118a52a82c4b93e326dc06bae96..c2c10c275dd6db5b49dd96f68b320ad7b35e0182 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-15  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64365
+       * gcc.dg/torture/pr64365.c: New testcase.
+
 2015-01-14  Marcos Diaz <marcos.diaz@tallertechnologies.com>
 
        * gcc.dg/stackprotectexplicit1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr64365.c b/gcc/testsuite/gcc.dg/torture/pr64365.c
new file mode 100644 (file)
index 0000000..169993e
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+extern int memcmp (const void * , const void *, __SIZE_TYPE__);
+
+void __attribute__((noinline,noclone))
+foo(int *in)
+{
+  int i;
+  for (i = 62; i >= 10; i--)
+    {
+      in[i - 8] -= in[i];
+      in[i - 5] += in[i] * 2;
+      in[i - 4] += in[i];
+    }
+}
+
+int main()
+{
+  int x[64];
+  int y[64] = { 0, 1, -2380134, -1065336, -1026376, 3264240, 3113534, 2328130, 3632054, 3839634, 2380136, 1065339, 1026380, 1496037, 1397286, 789976, 386408, 450984, 597112, 497464, 262008, 149184, 194768, 231519, 173984, 87753, 60712, 82042, 87502, 60014, 30050, 25550, 33570, 32386, 20464, 10675, 10868, 13329, 11794, 6892, 3988, 4564, 5148, 4228, 2284, 1568, 1848, 1943, 1472, 741, 628, 702, 714, 474, 230, 234, 238, 242, 120, 59, 60, 61, 62, 63 };
+  int i;
+
+  for (i = 0; i < 64; ++i)
+    {
+      x[i] = i;
+      __asm__ volatile ("");
+    }
+
+  foo (x);
+
+  if (memcmp (x, y, sizeof (x)) != 0)
+    abort ();
+
+  return 0;
+}
index 5c42e579bc02e82d23698755e0e7728bcf120bb9..20a31bb738f48d15f9d0d8748a034f59ec3b5131 100644 (file)
@@ -992,6 +992,22 @@ dr_analyze_indices (struct data_reference *dr, loop_p nest, loop_p loop)
                                fold_convert (ssizetype, memoff));
              memoff = build_int_cst (TREE_TYPE (memoff), 0);
            }
+         /* Adjust the offset so it is a multiple of the access type
+            size and thus we separate bases that can possibly be used
+            to produce partial overlaps (which the access_fn machinery
+            cannot handle).  */
+         wide_int rem;
+         if (TYPE_SIZE_UNIT (TREE_TYPE (ref))
+             && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (ref))) == INTEGER_CST
+             && !integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (ref))))
+           rem = wi::mod_trunc (off, TYPE_SIZE_UNIT (TREE_TYPE (ref)), SIGNED);
+         else
+           /* If we can't compute the remainder simply force the initial
+              condition to zero.  */
+           rem = off;
+         off = wide_int_to_tree (ssizetype, wi::sub (off, rem));
+         memoff = wide_int_to_tree (TREE_TYPE (memoff), rem);
+         /* And finally replace the initial condition.  */
          access_fn = chrec_replace_initial_condition
              (access_fn, fold_convert (orig_type, off));
          /* ???  This is still not a suitable base object for