From 1d60cc55298f5915b5d934c5f5398ebb5b03809c Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 24 Mar 2011 14:21:27 +0000 Subject: [PATCH] tree-sra.c (build_ref_for_offset): Strip useless type conversions from the address built for a reference with... * tree-sra.c (build_ref_for_offset): Strip useless type conversions from the address built for a reference with variable offset. From-SVN: r171393 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/array15.adb | 24 ++++++++++++++++++++++++ gcc/testsuite/gnat.dg/array15.ads | 5 +++++ gcc/tree-sra.c | 1 + 5 files changed, 39 insertions(+) create mode 100644 gcc/testsuite/gnat.dg/array15.adb create mode 100644 gcc/testsuite/gnat.dg/array15.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 238f6f0fdeb..c2e1bf4f12f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-03-24 Eric Botcazou + + * tree-sra.c (build_ref_for_offset): Strip useless type conversions + from the address built for a reference with variable offset. + 2011-03-24 Uros Bizjak PR target/48237 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b9b249d9d6..47200262263 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-03-24 Eric Botcazou + + * gnat.dg/array15.ad[sb]: New test. + 2011-03-24 Uros Bizjak PR target/48237 diff --git a/gcc/testsuite/gnat.dg/array15.adb b/gcc/testsuite/gnat.dg/array15.adb new file mode 100644 index 00000000000..eb51f37c5ae --- /dev/null +++ b/gcc/testsuite/gnat.dg/array15.adb @@ -0,0 +1,24 @@ +-- { dg-do compile } +-- { dg-options "-O -gnatws" } + +package body Array15 is + + type Arr is array (Natural range <>) of Integer; + + Table : Arr (1 .. 4); + + N : Natural := 1; + + procedure Zero is + begin + N := 0; + end; + + function F (I : Integer) return Integer is + A1 : Arr := (1 => I); + A2 : Arr := Table (1 .. N) & A1; + begin + return A2 (I); + end; + +end Array15; diff --git a/gcc/testsuite/gnat.dg/array15.ads b/gcc/testsuite/gnat.dg/array15.ads new file mode 100644 index 00000000000..c5c2087a62f --- /dev/null +++ b/gcc/testsuite/gnat.dg/array15.ads @@ -0,0 +1,5 @@ +package Array15 is + + function F (I : Integer) return Integer; + +end Array15; diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index f28719f5fe6..7ad0e098721 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1376,6 +1376,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset, add_referenced_var (tmp); tmp = make_ssa_name (tmp, NULL); addr = build_fold_addr_expr (unshare_expr (prev_base)); + STRIP_USELESS_TYPE_CONVERSION (addr); stmt = gimple_build_assign (tmp, addr); gimple_set_location (stmt, loc); SSA_NAME_DEF_STMT (tmp) = stmt; -- 2.30.2