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
This commit is contained in:
Eric Botcazou 2011-03-24 14:21:27 +00:00 committed by Eric Botcazou
parent c78dd519d3
commit 1d60cc5529
5 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2011-03-24 Eric Botcazou <ebotcazou@adacore.com>
* 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 <ubizjak@gmail.com>
PR target/48237

View File

@ -1,3 +1,7 @@
2011-03-24 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/array15.ad[sb]: New test.
2011-03-24 Uros Bizjak <ubizjak@gmail.com>
PR target/48237

View File

@ -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;

View File

@ -0,0 +1,5 @@
package Array15 is
function F (I : Integer) return Integer;
end Array15;

View File

@ -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;