Message ID | 1446546443-27379-1-git-send-email-alan.lawrence@arm.com |
---|---|
State | New |
Headers | show |
On 3 November 2015 at 10:27, Alan Lawrence <alan.lawrence@arm.com> wrote: > That is, ssa-dom-cse-7.c passes (and the patch series solves PR/63679) if > instead of my patch 2 (normalization of MEM_REFs) we have this: > > diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c > index 4327990..2889a96 100644 > --- a/gcc/tree-sra.c > +++ b/gcc/tree-sra.c > @@ -1697,7 +1697,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset, > } > else > { > - off = build_int_cst (reference_alias_ptr_type (base), > + off = build_int_cst (build_pointer_type (exp_type), > base_offset + offset / BITS_PER_UNIT); > base = build_fold_addr_expr (unshare_expr (base)); > } > > ...I'll test that fully but I have to wonder what the right path is here! So with also changing the other reference_alias_ptr_type in the first case of build_ref_for_offset, it breaks Ada ACATS (on x86): c52101a "CHECK THAT ARRAY SUBTYPE CONVERSION IS APPLIED AFTER AN ARRAY VALUE IS DETERMINED" cc70003 cxac004 (stream access, stream functions) ....I'll not dig any further unless you think that change to SRA is the right avenue to investigate! Cheers, Alan
On Tue, Nov 3, 2015 at 12:13 PM, Alan Lawrence <alan.lawrence@arm.com> wrote: > On 3 November 2015 at 10:27, Alan Lawrence <alan.lawrence@arm.com> wrote: >> That is, ssa-dom-cse-7.c passes (and the patch series solves PR/63679) if >> instead of my patch 2 (normalization of MEM_REFs) we have this: >> >> diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c >> index 4327990..2889a96 100644 >> --- a/gcc/tree-sra.c >> +++ b/gcc/tree-sra.c >> @@ -1697,7 +1697,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset, >> } >> else >> { >> - off = build_int_cst (reference_alias_ptr_type (base), >> + off = build_int_cst (build_pointer_type (exp_type), >> base_offset + offset / BITS_PER_UNIT); >> base = build_fold_addr_expr (unshare_expr (base)); >> } >> >> ...I'll test that fully but I have to wonder what the right path is here! > > So with also changing the other reference_alias_ptr_type in the first > case of build_ref_for_offset, it breaks Ada ACATS (on x86): > > c52101a "CHECK THAT ARRAY SUBTYPE CONVERSION IS APPLIED AFTER AN ARRAY > VALUE IS DETERMINED" > cc70003 > cxac004 (stream access, stream functions) > > ....I'll not dig any further unless you think that change to SRA is > the right avenue to investigate! Nope, that change looks wrong to me. Richard. > Cheers, Alan
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 4327990..2889a96 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1697,7 +1697,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset, } else { - off = build_int_cst (reference_alias_ptr_type (base), + off = build_int_cst (build_pointer_type (exp_type), base_offset + offset / BITS_PER_UNIT); base = build_fold_addr_expr (unshare_expr (base)); } ...I'll test that fully but I have to wonder what the right path is here! Cheers, Alan --- gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-5.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-6.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-7.c | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-5.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-6.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-7.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-5.c new file mode 100644 index 0000000..cfbb85f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-5.c @@ -0,0 +1,17 @@ +/* Test normalization of ARRAY_REF expressions to MEM_REFs in dom. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-dom2" } */ + +#define N 8 + +int +main (int argc, char **argv) +{ + int a[N]; + for (int i = 0; i < N; i++) + a[i] = 2*i + 1; + int *p = &a[0]; + return *(++p); +} + +/* { dg-final { scan-tree-dump-times "return 3;" 1 "dom2"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-6.c new file mode 100644 index 0000000..c387fa3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-6.c @@ -0,0 +1,16 @@ +/* Test normalization of ARRAY_REF expressions to MEM_REFs in dom. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-sra -fno-tree-fre -fdump-tree-dom1" } */ + +int +main (int argc, char **argv) +{ + union { + int a[8]; + int b[2]; + } u = { .a = { 1, 42, 3, 4, 5, 6, 7, 8 } }; + + return u.b[1]; +} + +/* { dg-final { scan-assembler-times "return 42;" 1 "dom1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-7.c new file mode 100644 index 0000000..3f4ca17 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-7.c @@ -0,0 +1,18 @@ +/* Test normalization of MEM_REF expressions in dom. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-fre -fno-tree-pre -fdump-tree-optimized" } + +typedef struct { + int a[8]; +} foo; + +foo f; + +int test () +{ + foo g = { { 1, 2, 3, 4, 5, 6, 7, 8 } }; + f=g; + return f.a[2]; +} + +/* { dg-final { scan-tree-dump-times "return 3;" 1 "optimized" } } */