diff options
author | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2013-04-17 11:22:07 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2013-04-17 11:22:07 +0000 |
commit | fc6f94f567e2a982dcba31dab027a49c196febf3 (patch) | |
tree | e92c611aff1949568c16e22a343380f90a7e4aeb /gcc | |
parent | 070edbc29c4f4a716cc6f4d9b038c9f38f9300a0 (diff) | |
download | gcc-fc6f94f567e2a982dcba31dab027a49c196febf3.zip gcc-fc6f94f567e2a982dcba31dab027a49c196febf3.tar.gz gcc-fc6f94f567e2a982dcba31dab027a49c196febf3.tar.bz2 |
tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
* 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
Diffstat (limited to 'gcc')
35 files changed, 328 insertions, 70 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a2408e6..440d3a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7bfc68d..4035e12 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..2b342db --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-38.c @@ -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" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-24-big-array.c b/gcc/testsuite/gcc.dg/vect/slp-24-big-array.c index 6c8f01c9..10b31aa 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-24-big-array.c +++ b/gcc/testsuite/gcc.dg/vect/slp-24-big-array.c @@ -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 (); diff --git a/gcc/testsuite/gcc.dg/vect/slp-24.c b/gcc/testsuite/gcc.dg/vect/slp-24.c index 61c53f0..eca66bf 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-24.c +++ b/gcc/testsuite/gcc.dg/vect/slp-24.c @@ -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 (); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-mult.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-mult.c index 779913a..8bc2c48 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-mult.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-mult.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i2.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i2.c index 25cabb6..dca34ef 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i2.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i4.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i4.c index 8f04b73..68114a6 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-i4.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-mult.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-mult.c index cd941a8..0b21522 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-mult.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u16-mult.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i2-gap.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i2-gap.c index 9b0142b..22030b0 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i2-gap.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i2-gap.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c index 6e3c9f1..ca8bd12 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2.c index 4fb5494..b1ce8052 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap2.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c index 5a44631..188e288 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7.c b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7.c index cc09fa6..87e6ce2 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-a-u8-i8-gap7.c @@ -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++) diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-mult-char-ls.c b/gcc/testsuite/gcc.dg/vect/vect-strided-mult-char-ls.c index 3c8062c..cc87729 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-mult-char-ls.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-mult-char-ls.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-mult.c b/gcc/testsuite/gcc.dg/vect/vect-strided-mult.c index 49399c4..3d2de09 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-mult.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-mult.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-same-dr.c b/gcc/testsuite/gcc.dg/vect/vect-strided-same-dr.c index f16aa1a..9768d72 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-same-dr.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-same-dr.c @@ -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 (); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i2.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i2.c index 6694897..5700684 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i2.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i4.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i4.c index 82a6c60..2e6fb02 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i4.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i4.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i4.c index d743fac..4c20488 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i4.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i8.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i8.c index 663f376..4dbd8d9 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u32-i8.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2-gap.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2-gap.c index 8055c9b..b83d54e 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2-gap.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2-gap.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2.c index be06437..962ba51 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i2.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c index cc1b949..473f560 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2.c index 349e869..4037572 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap2.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c index 916fdf4..da4b484 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c index 7cfac72..07e1a80 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4.c index 537bcc8..0079667 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap4.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c index ecacefa..9697aaa 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7.c index 76cb66d..854a4aa 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8-gap7.c @@ -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); diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8.c index ff80c04..37a0954 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u8-i8.c @@ -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 index 0000000..d5ace72 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr41.adb @@ -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 index 0000000..4af8f63 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr41.ads @@ -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; diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 968c505..70e9e00 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -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); diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c index f491c4e..f29690f 100644 --- a/gcc/tree-streamer.c +++ b/gcc/tree-streamer.c @@ -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); } } |