diff mbox

[C++] Remove last use of can_trust_pointer_alignment

Message ID alpine.LNX.2.00.1108111054130.810@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Aug. 11, 2011, 8:57 a.m. UTC
On Wed, 10 Aug 2011, Richard Guenther wrote:

> On Wed, 10 Aug 2011, Richard Guenther wrote:
> 
> > On Wed, 10 Aug 2011, Jason Merrill wrote:
> > 
> > > On 08/10/2011 08:35 AM, Richard Guenther wrote:
> > > > 	* call.c (build_over_call): Call memcpy unconditionally.
> > > 
> > > OK.  Have you tested the MEM_REF patch?
> > 
> > No, not yet.  I'll throw it to testing now.
> 
> The following is what passed bootstrap sofar and is in testing now.

With the patch SRA now causes g++.dg/tree-ssa/pr41186.C to be fully
optimized, making FRE useless.  Thus the patch needs to disable SRA
when testing for FRE features.  This is somewhat expected as
when no longer using memcpy nothing keeps the source/destination
having their address taken and thus they get exposed to SRA.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2011-08-11  Richard Guenther  <rguenther@suse.de>

	cp/
	* call.c (build_over_call): Instead of memcpy use an
	assignment of two MEM_REFs.

	* g++.dg/tree-ssa/pr41186.C: Disable SRA.

Comments

Jason Merrill Aug. 11, 2011, 5:49 p.m. UTC | #1
OK.

Jason
H.J. Lu Aug. 12, 2011, 2:05 p.m. UTC | #2
On Thu, Aug 11, 2011 at 1:57 AM, Richard Guenther <rguenther@suse.de> wrote:
> On Wed, 10 Aug 2011, Richard Guenther wrote:
>
>> On Wed, 10 Aug 2011, Richard Guenther wrote:
>>
>> > On Wed, 10 Aug 2011, Jason Merrill wrote:
>> >
>> > > On 08/10/2011 08:35 AM, Richard Guenther wrote:
>> > > >         * call.c (build_over_call): Call memcpy unconditionally.
>> > >
>> > > OK.  Have you tested the MEM_REF patch?
>> >
>> > No, not yet.  I'll throw it to testing now.
>>
>> The following is what passed bootstrap sofar and is in testing now.
>
> With the patch SRA now causes g++.dg/tree-ssa/pr41186.C to be fully
> optimized, making FRE useless.  Thus the patch needs to disable SRA
> when testing for FRE features.  This is somewhat expected as
> when no longer using memcpy nothing keeps the source/destination
> having their address taken and thus they get exposed to SRA.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?
>
> Thanks,
> Richard.
>
> 2011-08-11  Richard Guenther  <rguenther@suse.de>
>
>        cp/
>        * call.c (build_over_call): Instead of memcpy use an
>        assignment of two MEM_REFs.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50058
diff mbox

Patch

Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c	(revision 177625)
+++ gcc/cp/call.c	(working copy)
@@ -6766,19 +6766,22 @@  build_over_call (struct z_candidate *can
 	}
       else
 	{
-	  /* We must only copy the non-tail padding parts.
-	     Use __builtin_memcpy for the bitwise copy.  */
-	  tree arg0, arg1, arg2, t;
+	  /* We must only copy the non-tail padding parts.  */
+	  tree arg0, arg2, t;
+	  tree array_type, alias_set;
 
 	  arg2 = TYPE_SIZE_UNIT (as_base);
-	  arg1 = arg;
 	  arg0 = cp_build_addr_expr (to, complain);
 
-	  t = implicit_built_in_decls[BUILT_IN_MEMCPY];
-	  t = build_call_n (t, 3, arg0, arg1, arg2);
-
-	  t = convert (TREE_TYPE (arg0), t);
-	  val = cp_build_indirect_ref (t, RO_NULL, complain);
+	  array_type = build_array_type (char_type_node,
+					 build_index_type
+					   (size_binop (MINUS_EXPR,
+							arg2, size_int (1))));
+	  alias_set = build_int_cst (build_pointer_type (type), 0);
+	  t = build2 (MODIFY_EXPR, void_type_node,
+		      build2 (MEM_REF, array_type, arg0, alias_set),
+		      build2 (MEM_REF, array_type, arg, alias_set));
+	  val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to);
           TREE_NO_WARNING (val) = 1;
 	}
 
Index: gcc/testsuite/g++.dg/tree-ssa/pr41186.C
===================================================================
--- gcc/testsuite/g++.dg/tree-ssa/pr41186.C	(revision 177625)
+++ gcc/testsuite/g++.dg/tree-ssa/pr41186.C	(working copy)
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-fre1-details" } */
+/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */
 
 struct Foo {
   Foo() {};