From patchwork Thu Aug 11 08:57:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 109570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 70CF0B6F8D for ; Thu, 11 Aug 2011 18:57:34 +1000 (EST) Received: (qmail 405 invoked by alias); 11 Aug 2011 08:57:31 -0000 Received: (qmail 395 invoked by uid 22791); 11 Aug 2011 08:57:30 -0000 X-SWARE-Spam-Status: No, hits=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_CP X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Aug 2011 08:57:15 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 860C38B2F9; Thu, 11 Aug 2011 10:57:14 +0200 (CEST) Date: Thu, 11 Aug 2011 10:57:14 +0200 (CEST) From: Richard Guenther To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH][C++] Remove last use of can_trust_pointer_alignment In-Reply-To: Message-ID: References: <4E429BBB.4020105@redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 cp/ * call.c (build_over_call): Instead of memcpy use an assignment of two MEM_REFs. * g++.dg/tree-ssa/pr41186.C: Disable SRA. 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() {};