From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2118 invoked by alias); 8 Jul 2011 14:35:23 -0000 Received: (qmail 2033 invoked by uid 22791); 8 Jul 2011 14:35:21 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL,BAYES_00,TW_CP,TW_TM,T_RP_MATCHES_RCVD 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; Fri, 08 Jul 2011 14:35:05 +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 2CBBB8D167; Fri, 8 Jul 2011 16:35:04 +0200 (CEST) Date: Fri, 08 Jul 2011 14:35:00 -0000 From: Michael Matz To: "Paulo J. Matos" Cc: gcc@gcc.gnu.org Subject: Re: gcc 4.6.1 expand is playing tricks on me In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00096.txt.bz2 Hi, On Fri, 8 Jul 2011, Paulo J. Matos wrote: > gcc4.5.3 hits continue the first time it gets there and gcc4.6.1 fails > the inner if and enters expand_gimple_stmt twice. Yes, the MEMREF branch merge disabled TER (temporary expression replacement, tree-ssa-ter.c) for loads with stores that possibly alias, because expand doesn't deal correctly with all cases. Without TERing these two instructions expand won't see both memory references at the same time, and hence generate separate load and store instruction, instead of a mem-mem move if that's supported on your target (I assume so, otherwise you wouldn't have noticed). The question is, why doesn't combine merge the two separate load and store insns again into one? If you feel adventurous you can try with the below patch. Test it also with the following testcase: --------------------------- char str[9] = "1234"; void bar (void) { unsigned int temp; char *p = &str[2]; memcpy (&temp, &str[1], 4); memcpy (p, &temp, 4); } --------------------------- If expand still has the problem and you apply the patch, then on some targets this will emit wrong instructions because the two sides of the MEM-MEM assignment implicitely constructed and given to expand will partially overlap. Ciao, Michael. -- Index: tree-ssa-ter.c =================================================================== --- tree-ssa-ter.c (revision 175921) +++ tree-ssa-ter.c (working copy) @@ -638,6 +638,7 @@ find_replaceable_in_bb (temp_expr_table_ is a load aliasing it avoid creating overlapping assignments which we cannot expand correctly. */ if (gimple_vdef (stmt) + && 0 && gimple_assign_single_p (stmt)) { gimple def_stmt = SSA_NAME_DEF_STMT (use);