]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 17 Apr 2013 11:22:07 +0000 (11:22 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 17 Apr 2013 11:22:07 +0000 (11:22 +0000)
* tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
(decl_refs_may_alias_p): Add REF1 and REF2 parameters.
Use nonoverlapping_component_refs_of_decl_p to disambiguate component
references.
(refs_may_alias_p_1): Adjust call to decl_refs_may_alias_p.
* tree-streamer.c (record_common_node): Adjust reference in comment.

From-SVN: r198024

35 files changed:
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-38.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/slp-24-big-array.c
gcc/testsuite/gcc.dg/vect/slp-24.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-mult.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i2.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i4.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-mult.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i2-gap.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c
gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7.c
gcc/testsuite/gcc.dg/vect/vect-strided-mult-char-ls.c
gcc/testsuite/gcc.dg/vect/vect-strided-mult.c
gcc/testsuite/gcc.dg/vect/vect-strided-same-dr.c
gcc/testsuite/gcc.dg/vect/vect-strided-u16-i2.c
gcc/testsuite/gcc.dg/vect/vect-strided-u16-i4.c
gcc/testsuite/gcc.dg/vect/vect-strided-u32-i4.c
gcc/testsuite/gcc.dg/vect/vect-strided-u32-i8.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2-gap.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7.c
gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8.c
gcc/testsuite/gnat.dg/discr41.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/discr41.ads [new file with mode: 0644]
gcc/tree-ssa-alias.c
gcc/tree-streamer.c

index a2408e6e7dd3cc8cf69332535d0d98e0cc5e39fe..440d3a1a097240e6b5be6a63bfe0d6aa10d38c2a 100644 (file)
@@ -1,3 +1,12 @@
+2013-04-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
+       (decl_refs_may_alias_p): Add REF1 and REF2 parameters.
+       Use nonoverlapping_component_refs_of_decl_p to disambiguate component
+       references.
+       (refs_may_alias_p_1): Adjust call to decl_refs_may_alias_p.
+       * tree-streamer.c (record_common_node): Adjust reference in comment.
+
 2013-04-17  Terry Guo  <terry.guo@arm.com>
 
        * config/arm/cortex-m4.md: Add a new bypass.
index 7bfc68db9dd67e5ef8c2c907241ad6b214cf7150..4035e12dcf3d3644e3d6a9159f5e479ae981cc9b 100644 (file)
@@ -1,9 +1,41 @@
+2013-04-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/discr41.ad[sb]: New test.
+       * gcc.dg/tree-ssa/ssa-fre-38.c: Likewise.
+       * gcc.dg/vect/slp-24-big-array.c: Beef up anti-vectorization trick.
+       * gcc.dg/vect/slp-24.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-mult.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u16-i2.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u16-i4.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u16-mult.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u8-i2-gap.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u8-i8-gap2.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c: Likewise.
+       * gcc.dg/vect/vect-strided-a-u8-i8-gap7.c: Likewise.
+       * gcc.dg/vect/vect-strided-mult-char-ls.c: Likewise.
+       * gcc.dg/vect/vect-strided-mult.c: Likewise.
+       * gcc.dg/vect/vect-strided-same-dr.c: Likewise.
+       * gcc.dg/vect/vect-strided-u16-i2.c: Likewise.
+       * gcc.dg/vect/vect-strided-u16-i4.c: Likewise.
+       * gcc.dg/vect/vect-strided-u32-i4.c: Likewise.
+       * gcc.dg/vect/vect-strided-u32-i8.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i2-gap.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i2.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap2.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap4.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8-gap7.c: Likewise.
+       * gcc.dg/vect/vect-strided-u8-i8.c: Likewise.
+
 2013-04-17  Janne Blomqvist  <jb@gcc.gnu.org>
 
-        PR fortran/40958
-        * lib/gcc-dg.exp (scan-module): Uncompress module file before
-        scanning.
-        * gfortran.dg/module_md5_1.f90: Remove.
+       PR fortran/40958
+       * lib/gcc-dg.exp (scan-module): Uncompress module file before scanning.
+       * gfortran.dg/module_md5_1.f90: Remove.
 
 2013-04-16   Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-38.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-38.c
new file mode 100644 (file)
index 0000000..2b342db
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1" } */
+
+struct S { int i; int j; };
+
+struct U
+{
+  struct S a[10];
+} u;
+
+int foo (int n, int i, int j)
+{
+  u.a[n].i = i;
+  u.a[n].j = j;
+  return u.a[n].i;
+}
+
+/* We should remove the redundant load.  */
+
+/* { dg-final { scan-tree-dump-not "= u.a\\\[n_2\\(D\\)\\\].i" "fre1" } } */
+/* { dg-final { cleanup-tree-dump "fre1" } } */
index 6c8f01c97497abc4862c77dff715bae77146fcea..10b31aaac37571dadd8284bb8057de2520ab1823 100644 (file)
@@ -84,8 +84,8 @@ int main (void)
       arr[i].b = i * 2 + 10;
       arr[i].c = 17;
       arr[i].d = i+34;
-      if (arr[i].a == 178)
-         abort ();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
   check_vect ();
 
index 61c53f08fa688021147e79f9ce6ecc0b0bc460d7..eca66bfb0364659ccc75adb447d5066ad6f6fc6d 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
 unsigned char ub[N*2] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
 unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
 
+volatile int y = 0;
+
 void
 main1 (unsigned char x, unsigned char max_result, unsigned char min_result, s *arr)
 {
@@ -67,8 +69,8 @@ int main (void)
       arr[i].b = i * 2 + 10;
       arr[i].c = 17;
       arr[i].d = i+34;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
   check_vect ();
   
index 779913a4f2ba7cb54640a931cce9f431cb7e9364..8bc2c48dbced0242e3a25950e03345834d509804 100644 (file)
@@ -15,6 +15,8 @@ typedef struct {
    unsigned int b;
 } ii;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -32,8 +34,8 @@ main1 ()
       arr[i].b = i * 2;
       iarr[i].a = i;
       iarr[i].b = i * 3;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 25cabb693c5d505fab867a6f9603aec0ec1e0bbe..dca34ef1f2998df2261f8a0fb941f382187ce258 100644 (file)
@@ -10,6 +10,8 @@ typedef struct {
    unsigned short b;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -22,8 +24,8 @@ main1 ()
     {
       arr[i].a = i;
       arr[i].b = i * 2;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 8f04b730f5795f9e17d344464ad882e84d19798f..68114a6824915840ce073595a3409610730b324c 100644 (file)
@@ -12,6 +12,8 @@ typedef struct {
    unsigned short d;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -27,8 +29,8 @@ main1 ()
       arr[i].b = i * 2;
       arr[i].c = 17;
       arr[i].d = i+34;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index cd941a827f1643991aff83363fd930b0118548c4..0b21522498f087d5f89abdcb0af17135f42c0bd3 100644 (file)
@@ -10,6 +10,8 @@ typedef struct {
    unsigned short b;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -26,8 +28,8 @@ main1 ()
       arr[i].a = i;
       arr[i].b = i * 2;
       iarr[i] = i * 3;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 9b0142b1d8d639fdad0488cc21a779b57e7fa9a6..22030b06ba8c5e0571d156e78466c4a40b9fe921 100644 (file)
@@ -10,6 +10,8 @@ typedef struct {
    unsigned char b;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -22,8 +24,8 @@ main1 ()
     {
       arr[i].a = i;
       arr[i].b = i * 2;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 6e3c9f1b9ae6f882badb9263654c0b33ac24a6a4..ca8bd12825c1db23a861c9565f7644318491609d 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -45,8 +47,8 @@ main1 ()
       check_res[i].h = arr[i].f;
       check_res[i].g = arr[i].f - arr[i].a;
 
-      if (arr[i].a == 178)
-         abort ();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 4fb5494a4d35e773621cd035a5bfbaf741d7b4fd..b1ce8052a3815aad3c113e6c24b3b4cd01d6ac3a 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -34,8 +36,8 @@ main1 ()
       arr[i].f = i * 2 + 2;
       arr[i].g = i - 3;
       arr[i].h = 56;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 5a446317ca3355390bac9ec1479a3df1bd78e538..188e288238536d043fb4a869fac3ba563f76f609 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -50,8 +52,8 @@ main1 ()
       check_res[i].h = arr[i].d;
       check_res[i].g = u + t;
 
-      if (arr[i].a == 178)
-         abort ();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index cc09fa608dcb67388bcf176fbcf9b076708a1c3c..87e6ce22e649eb376cd0a6bc81da0dc5e368baf3 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 ()
 {
@@ -35,8 +37,8 @@ main1 ()
       arr[i].f = i * 5;
       arr[i].g = i - 3;
       arr[i].h = 67;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   for (i = 0; i < N; i++)
index 3c8062cea123367b217ea6e6b5c3d0c971613cf3..cc877293cea72c774893e62865b6c3d4b92e7e92 100644 (file)
@@ -15,6 +15,8 @@ typedef struct {
    unsigned int b;
 } ii;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr, ii *iarr)
 {
@@ -62,8 +64,8 @@ int main (void)
       arr[i].b = i * 2;
       iarr[i].a = i;
       iarr[i].b = i * 3;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   main1 (arr, iarr);
index 49399c4e78c68a5de4a411aa3b9a1931db1a2fcd..3d2de09cbb0e950bbfa776b660c6529d16c1f76f 100644 (file)
@@ -15,6 +15,8 @@ typedef struct {
    unsigned int b;
 } ii;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr, ii *iarr)
 {
@@ -62,8 +64,8 @@ int main (void)
       arr[i].b = i * 2;
       iarr[i].a = i;
       iarr[i].b = i * 3;
-      if (arr[i].a == 178)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   main1 (arr, iarr); 
index f16aa1a94d739d82c3382eb37614be113d0af964..9768d72636a8b64a0f11a604506a80aa5e4f65c5 100644 (file)
@@ -12,6 +12,8 @@ typedef struct {
 
 s buffer1[N], buffer2[N];
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s * __restrict__  pIn, s* __restrict__ pOut)
 {
@@ -61,8 +63,8 @@ int main (void)
       buffer1[i].b = i + 8;
       buffer2[i].a = i * 3;
       buffer2[i].b = i * 2;
-      if (buffer1[i].a == 500)
-         abort();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   check_vect ();
index 6694897316ecf9533a35319c8124ee09d7f184f4..57006846ff2f90568553eda09c2e58cc6bcbc289 100644 (file)
@@ -10,6 +10,8 @@ typedef struct {
    unsigned short b;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -46,8 +48,8 @@ int main (void)
     { 
       arr[i].a = i;
       arr[i].b = i * 2;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index 82a6c6056747bb1ef43235e80f84f69f45848c9e..2e6fb02b81782e8acbe63453a7e848fc9714afa7 100644 (file)
@@ -12,6 +12,8 @@ typedef struct {
    unsigned short d;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -59,8 +61,8 @@ int main (void)
       arr[i].b = i * 2;
       arr[i].c = 17;
       arr[i].d = i+34;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index d743fac1d62958802360131192e47dd945476e6d..4c2048820a11a52a43cdb531d4c9ce7d83788080 100644 (file)
@@ -12,6 +12,8 @@ typedef struct {
    int d;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -54,8 +56,8 @@ int main (void)
       arr[i].b = i * 2;
       arr[i].c = 17;
       arr[i].d = i+34;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index 663f3763249b74549c47cecf5cbd7442e8f7f54a..4dbd8d9ab3c1862256509695cd88a47fee628e9e 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    int h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -68,8 +70,8 @@ int main (void)
       arr[i].f = i * 5;
       arr[i].g = i - 3;
       arr[i].h = 56;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index 8055c9b5f8fc050c5a27c031db430cc5a33324d9..b83d54e2e3741622d85124f237ae4ec8f4c0c105 100644 (file)
@@ -10,6 +10,8 @@ typedef struct {
    unsigned char b;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -62,8 +64,8 @@ int main (void)
     { 
       arr[i].a = i;
       arr[i].b = i * 2;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index be06437550ef07ecca17c2b11968c812c14ef282..962ba51bd5f90b66b089a7bee29fae6054950636 100644 (file)
@@ -10,6 +10,8 @@ typedef struct {
    unsigned char b;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -45,8 +47,8 @@ int main (void)
     { 
       arr[i].a = i;
       arr[i].b = i * 2;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index cc1b94989149c847ae63c45063a22d20fe1ae196..473f560511a78cf31f664bf71bb9ee6dc816a771 100644 (file)
@@ -18,6 +18,8 @@ typedef struct {
 
 s check_res[N];
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -80,8 +82,9 @@ int main (void)
       check_res[i].e = arr[i].f - arr[i].b;
       check_res[i].h = arr[i].f;
       check_res[i].g = arr[i].f - arr[i].b;
-      if (arr[i].a == 178)
-         abort ();
+
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   main1 (arr);
index 349e869392609be6894ac0634d06ac6f2644a29f..4037572d9700753c4d5b191642804b7eaaa779e8 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -69,8 +71,8 @@ int main (void)
       arr[i].f = i * 2 + 2;
       arr[i].g = i - 3;
       arr[i].h = 56;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index 916fdf4d4fa24f1ad462d55e3974641bfa93bfc1..da4b484b1ae3670ca604a661d2a92cb4e6ea9f89 100644 (file)
@@ -18,6 +18,8 @@ typedef struct {
 
 s check_res[N];
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -103,8 +105,8 @@ int main (void)
       check_res[i].h = arr[i].c;
       check_res[i].g = arr[i].b + arr[i].c;
 
-      if (arr[i].a == 178)
-         abort ();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
   main1 (arr);
 
index 7cfac72d7f11839366ddb2ba807cfe72d44fa076..07e1a803f7c001699c620a2900b7de8ce9970de7 100644 (file)
@@ -17,6 +17,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr, int n)
 {
@@ -102,8 +104,8 @@ int main (void)
       arr[i].f = 16;
       arr[i].g = 3;
       arr[i].h = 56;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr, N-2);
index 537bcc87dfb573731e4e662adf4251a04dd0afce..007966704801bce3dac7712c1e8c98cf2c3a65aa 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -89,8 +91,8 @@ int main (void)
       arr[i].f = i * 5;
       arr[i].g = i - 3;
       arr[i].h = 56;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index ecacefab9a5ed96d11e6f331909f237aa975351e..9697aaa8b6f4c2bf43c08d968d08a1acd80930d5 100644 (file)
@@ -18,6 +18,8 @@ typedef struct {
 
 s check_res[N];
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -91,8 +93,8 @@ int main (void)
       check_res[i].h = arr[i].d;
       check_res[i].g = u + t;
 
-      if (arr[i].a == 178)
-         abort ();
+      if (y) /* Avoid vectorization.  */
+        abort ();
     }
 
   main1 (arr);
index 76cb66d0861c09c16752462742cc614f8d15e143..854a4aaabb835ee662864e272e4e7493ab39fe39 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -74,8 +76,8 @@ int main (void)
       arr[i].f = i * 5;
       arr[i].g = i - 3;
       arr[i].h = 67;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
index ff80c0418e9a54ad097f677db63c8424deb69270..37a0954001e3bd4edd6ed6bc41be59fded191a93 100644 (file)
@@ -16,6 +16,8 @@ typedef struct {
    unsigned char h;
 } s;
 
+volatile int y = 0;
+
 __attribute__ ((noinline)) int
 main1 (s *arr)
 {
@@ -76,8 +78,8 @@ int main (void)
       arr[i].f = i + 5;
       arr[i].g = i + 3;
       arr[i].h = 67;
-      if (arr[i].a == 178)
-         abort(); 
+      if (y) /* Avoid vectorization.  */
+        abort ();
     } 
 
   main1 (arr);
diff --git a/gcc/testsuite/gnat.dg/discr41.adb b/gcc/testsuite/gnat.dg/discr41.adb
new file mode 100644 (file)
index 0000000..d5ace72
--- /dev/null
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Discr41 is
+
+   function F return Rec is
+      Ret : Rec (0);
+   begin
+      return Ret;
+   end;
+
+end Discr41;
diff --git a/gcc/testsuite/gnat.dg/discr41.ads b/gcc/testsuite/gnat.dg/discr41.ads
new file mode 100644 (file)
index 0000000..4af8f63
--- /dev/null
@@ -0,0 +1,20 @@
+package Discr41 is
+
+   type Vector is array (Positive range <>) of Long_Float;
+
+   type Date is record
+      LF : Long_Float := 0.0;
+   end record;
+
+   type Date_Vector is array (Positive range <>) of Date;
+
+   type Rec (D : Natural) is record
+      B1 : Boolean := False;
+      DL : Date_Vector (1 .. D);
+      VL : Vector (1 .. D) := (others => 0.0);
+      B2 : Boolean := True;
+   end record;
+
+   function F return Rec;
+
+end Discr41;
index 968c50548938a21b7b186950e8344ea8f75143d9..70e9e00878348c5183e53b11032b2e4390dec9ca 100644 (file)
@@ -719,14 +719,113 @@ aliasing_component_refs_p (tree ref1,
   return false;
 }
 
+/* Return true if we can determine that component references REF1 and REF2,
+   that are within a common DECL, cannot overlap.  */
+
+static bool
+nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
+{
+  vec<tree, va_stack> component_refs1;
+  vec<tree, va_stack> component_refs2;
+
+  vec_stack_alloc (tree, component_refs1, 16);
+  vec_stack_alloc (tree, component_refs2, 16);
+
+  /* Create the stack of handled components for REF1.  */
+  while (handled_component_p (ref1))
+    {
+      component_refs1.safe_push (ref1);
+      ref1 = TREE_OPERAND (ref1, 0);
+    }
+  if (TREE_CODE (ref1) == MEM_REF)
+    {
+      if (!integer_zerop (TREE_OPERAND (ref1, 1)))
+       goto may_overlap;
+      ref1 = TREE_OPERAND (TREE_OPERAND (ref1, 0), 0);
+    }
+
+  /* Create the stack of handled components for REF2.  */
+  while (handled_component_p (ref2))
+    {
+      component_refs2.safe_push (ref2);
+      ref2 = TREE_OPERAND (ref2, 0);
+    }
+  if (TREE_CODE (ref2) == MEM_REF)
+    {
+      if (!integer_zerop (TREE_OPERAND (ref2, 1)))
+       goto may_overlap;
+      ref2 = TREE_OPERAND (TREE_OPERAND (ref2, 0), 0);
+    }
+
+  /* We must have the same base DECL.  */
+  gcc_assert (ref1 == ref2);
+
+  /* Pop the stacks in parallel and examine the COMPONENT_REFs of the same
+     rank.  This is sufficient because we start from the same DECL and you
+     cannot reference several fields at a time with COMPONENT_REFs (unlike
+     with ARRAY_RANGE_REFs for arrays) so you always need the same number
+     of them to access a sub-component, unless you're in a union, in which
+     case the return value will precisely be false.  */
+  while (true)
+    {
+      do
+       {
+         if (component_refs1.is_empty ())
+           goto may_overlap;
+         ref1 = component_refs1.pop ();
+       }
+      while (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (ref1, 0))));
+
+      do
+       {
+         if (component_refs2.is_empty ())
+            goto may_overlap;
+         ref2 = component_refs2.pop ();
+       }
+      while (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (ref2, 0))));
+
+      /* Beware of BIT_FIELD_REF.  */
+      if (TREE_CODE (ref1) != COMPONENT_REF
+         || TREE_CODE (ref2) != COMPONENT_REF)
+       goto may_overlap;
+
+      tree field1 = TREE_OPERAND (ref1, 1);
+      tree field2 = TREE_OPERAND (ref2, 1);
+
+      /* ??? We cannot simply use the type of operand #0 of the refs here
+        as the Fortran compiler smuggles type punning into COMPONENT_REFs
+        for common blocks instead of using unions like everyone else.  */
+      tree type1 = TYPE_MAIN_VARIANT (DECL_CONTEXT (field1));
+      tree type2 = TYPE_MAIN_VARIANT (DECL_CONTEXT (field2));
+
+      /* We cannot disambiguate fields in a union or qualified union.  */
+      if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE)
+        goto may_overlap;
+
+      /* Different fields of the same record type cannot overlap.  */
+      if (field1 != field2)
+       {
+         component_refs1.release ();
+         component_refs2.release ();
+         return true;
+       }
+    }
+
+may_overlap:
+  component_refs1.release ();
+  component_refs2.release ();
+  return false;
+}
+
 /* Return true if two memory references based on the variables BASE1
    and BASE2 constrained to [OFFSET1, OFFSET1 + MAX_SIZE1) and
-   [OFFSET2, OFFSET2 + MAX_SIZE2) may alias.  */
+   [OFFSET2, OFFSET2 + MAX_SIZE2) may alias.  REF1 and REF2
+   if non-NULL are the complete memory reference trees.  */
 
 static bool
-decl_refs_may_alias_p (tree base1,
+decl_refs_may_alias_p (tree ref1, tree base1,
                       HOST_WIDE_INT offset1, HOST_WIDE_INT max_size1,
-                      tree base2,
+                      tree ref2, tree base2,
                       HOST_WIDE_INT offset2, HOST_WIDE_INT max_size2)
 {
   gcc_checking_assert (DECL_P (base1) && DECL_P (base2));
@@ -737,7 +836,17 @@ decl_refs_may_alias_p (tree base1,
 
   /* If both references are based on the same variable, they cannot alias if
      the accesses do not overlap.  */
-  return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
+  if (!ranges_overlap_p (offset1, max_size1, offset2, max_size2))
+    return false;
+
+  /* For components with variable position, the above test isn't sufficient,
+     so we disambiguate component references manually.  */
+  if (ref1 && ref2
+      && handled_component_p (ref1) && handled_component_p (ref2)
+      && nonoverlapping_component_refs_of_decl_p (ref1, ref2))
+    return false;
+
+  return true;     
 }
 
 /* Return true if an indirect reference based on *PTR1 constrained
@@ -1086,8 +1195,8 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
   var1_p = DECL_P (base1);
   var2_p = DECL_P (base2);
   if (var1_p && var2_p)
-    return decl_refs_may_alias_p (base1, offset1, max_size1,
-                                 base2, offset2, max_size2);
+    return decl_refs_may_alias_p (ref1->ref, base1, offset1, max_size1,
+                                 ref2->ref, base2, offset2, max_size2);
 
   ind1_p = (TREE_CODE (base1) == MEM_REF
            || TREE_CODE (base1) == TARGET_MEM_REF);
index f491c4ee6c41fffea54d7192537bac1c0c2698bf..f29690f62b9b3ffdad6037e681f2d3d0ecd5edf0 100644 (file)
@@ -267,10 +267,10 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
       /* The FIELD_DECLs of structures should be shared, so that every
         COMPONENT_REF uses the same tree node when referencing a field.
         Pointer equality between FIELD_DECLs is used by the alias
-        machinery to compute overlapping memory references (See
-        nonoverlapping_component_refs_p).  */
-      tree f;
-      for (f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
+        machinery to compute overlapping component references (see
+        nonoverlapping_component_refs_p and
+        nonoverlapping_component_refs_of_decl_p).  */
+      for (tree f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
        record_common_node (cache, f);
     }
 }