]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* tree-ssa-alias.c (nonoverlapping_refs_since_match_p): Do not
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 20 Oct 2019 18:53:37 +0000 (18:53 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 20 Oct 2019 18:53:37 +0000 (18:53 +0000)
skip non-zero array accesses.

* gcc.c-torture/execute/alias-access-path-2.c: New testcase.
* gcc.dg/tree-ssa/alias-access-path-11.c: xfail.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/alias-access-path-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-11.c
gcc/tree-ssa-alias.c

index f35cb40e2d64e395d590b8cf09014ac6a76a6dca..fec3514269a9659c52ffc5e10e40f9ae58193fc9 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-20  Jan Hubicka  <hubicka@ucw.cz>
+
+       * tree-ssa-alias.c (nonoverlapping_refs_since_match_p): Do not
+       skip non-zero array accesses.
+
 2019-10-20  Richard Sandiford  <richard.sandiford@arm.com>
 
        * tree-vect-slp.c (vect_slp_analyze_bb_1): Take a bb_vec_info
index d03774bb616156459bb8a86a2a91954c19aed278..681cee69de494e704f353685ab8bd0e496fccf7b 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-20  Jan Hubicka  <hubicka@ucw.cz>
+
+       * gcc.c-torture/execute/alias-access-path-2.c: New testcase.
+       * gcc.dg/tree-ssa/alias-access-path-11.c: xfail.
+
 2019-10-20  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/cpp2a/nodiscard-reason-only-one.C: In dg-error or dg-warning
diff --git a/gcc/testsuite/gcc.c-torture/execute/alias-access-path-2.c b/gcc/testsuite/gcc.c-torture/execute/alias-access-path-2.c
new file mode 100644 (file)
index 0000000..6dab37c
--- /dev/null
@@ -0,0 +1,11 @@
+int
+main (int argc, char **argv)
+{
+  int c;
+  unsigned char out[][1] = { {71}, {71}, {71} };
+
+  for (int i = 0; i < 3; i++)
+    if (!out[i][0])
+      __builtin_abort ();
+  return 0;
+}
index 1f8371431eae8a1f24fd70f5f8c839cd231e9e4d..45d1b74e6422bade3edf38e406e7a42d22e06ae7 100644 (file)
@@ -12,4 +12,4 @@ test(int i,int j)
   (*innerptr)[3][j]=11;
   return (*barptr)[i][2][j];
 }
-/* { dg-final { scan-tree-dump-times "return 10" 1 "fre3"} } */
+/* { dg-final { scan-tree-dump-times "return 10" 1 "fre3" { xfail *-*-* } } } */
index d6c443848ab7a99c09626ff1fe59d4a84c994842..4cfe3e2b4378193ac569276e676322e1cc77f03e 100644 (file)
@@ -1444,20 +1444,36 @@ nonoverlapping_refs_since_match_p (tree match1, tree ref1,
          for (; narray_refs1 > narray_refs2; narray_refs1--)
            {
              ref1 = component_refs1.pop ();
-             /* Track whether we possibly introduced partial overlap assuming
-                that innermost type sizes does not match.  This only can
-                happen if the offset introduced by the ARRAY_REF
-                is non-zero.  */
+
+             /* If index is non-zero we need to check whether the reference
+                does not break the main invariant that bases are either
+                disjoint or equal.  Consider the example:
+
+                unsigned char out[][1];
+                out[1]="a";
+                out[i][0];
+
+                Here bases out and out are same, but after removing the
+                [i] index, this invariant no longer holds, because
+                out[i] points to the middle of array out.
+
+                TODO: If size of type of the skipped reference is an integer
+                multiply of the size of type of the other reference this
+                invariant can be verified, but even then it is not completely
+                safe with !flag_strict_aliasing if the other reference contains
+                unbounded array accesses.
+                See   */
+
              if (!operand_equal_p (TREE_OPERAND (ref1, 1),
                                    cheap_array_ref_low_bound (ref1), 0))
-               seen_unmatched_ref_p = true;
+               return 0;
            }
          for (; narray_refs2 > narray_refs1; narray_refs2--)
            {
              ref2 = component_refs2.pop ();
              if (!operand_equal_p (TREE_OPERAND (ref2, 1),
                                    cheap_array_ref_low_bound (ref2), 0))
-               seen_unmatched_ref_p = true;
+               return 0;
            }
          /* Try to disambiguate matched arrays.  */
          for (unsigned int i = 0; i < narray_refs1; i++)