expr.c (expand_expr_real_1): Do not unnecessarily copy the object in the MEM_P case.

* expr.c (expand_expr_real_1) <VIEW_CONVERT_EXPR>: Do not unnecessarily
	copy the object in the MEM_P case.

From-SVN: r192452
This commit is contained in:
Eric Botcazou 2012-10-15 10:48:17 +00:00 committed by Eric Botcazou
parent 0127aae46a
commit 9506aecb3b
5 changed files with 52 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2012-10-15 Eric Botcazou <ebotcazou@adacore.com>
* expr.c (expand_expr_real_1) <VIEW_CONVERT_EXPR>: Do not unnecessarily
copy the object in the MEM_P case.
2012-10-15 Richard Guenther <rguenther@suse.de>
* tree-streamer-out.c (streamer_pack_tree_bitfields): Back
@ -37,7 +42,6 @@
(build_insn_chain): Use df_get_live_out instead of DF_LR_OUT.
(do_reload): Remove the DF_LIVE problem for -O1.
2012-10-14 Steven Bosscher <steven@gcc.gnu.org>
PR rtl-optimization/54919

View file

@ -10270,10 +10270,15 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
{
enum insn_code icode;
op0 = copy_rtx (op0);
if (TYPE_ALIGN_OK (type))
set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type)));
{
/* ??? Copying the MEM without substantially changing it might
run afoul of the code handling volatile memory references in
store_expr, which assumes that TARGET is returned unmodified
if it has been used. */
op0 = copy_rtx (op0);
set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type)));
}
else if (mode != BLKmode
&& MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode)
/* If the target does have special handling for unaligned

View file

@ -1,3 +1,7 @@
2012-10-15 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/unchecked_convert9.ad[sb]: New test.
2012-10-13 Jason Merrill <jason@redhat.com>
* g++.dg/tls/thread_local7g.C: Require tls_native.

View file

@ -0,0 +1,15 @@
-- { dg-do compile }
-- { dg-options "-O -fdump-rtl-final" }
package body Unchecked_Convert9 is
procedure Proc is
L : Unsigned_32 := 16#55557777#;
begin
Var := Conv (L);
end;
end Unchecked_Convert9;
-- { dg-final { scan-rtl-dump-times "set \\(mem/v" 1 "final" } }
-- { dg-final { cleanup-rtl-dump "final" } }

View file

@ -0,0 +1,20 @@
with System;
with Ada.Unchecked_Conversion;
with Interfaces; use Interfaces;
package Unchecked_Convert9 is
type R is record
H : Unsigned_16;
L : Unsigned_16;
end record;
Var : R;
pragma Volatile (Var);
function Conv is new
Ada.Unchecked_Conversion (Source => Unsigned_32, Target => R);
procedure Proc;
end Unchecked_Convert9;