From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91756 invoked by alias); 28 Nov 2017 11:58:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 91685 invoked by uid 89); 28 Nov 2017 11:58:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=103924 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Nov 2017 11:57:59 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AB75DAE0F for ; Tue, 28 Nov 2017 11:57:57 +0000 (UTC) Date: Tue, 28 Nov 2017 12:24:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH][2/2] gimple-fold.c part for PR83141 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-11/txt/msg02398.txt.bz2 On Mon, 27 Nov 2017, Richard Biener wrote: > > The following is the truly minimal fix for the middle-end issue > with SRA and memcpy folding interaction. I've tried more variants > that "make sense" but as they all end up folding slightly more > memcpy calls than before we run into optimization testcase > regressions in places that look for __builtin_memcpy and do > not deal with aggregate copies as MEM[..] = MEM[..]; > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > GCC 9 is the time we can try dealing with such fallout, it just > doesn't feel like the correct time to do now... Installed as follows, bootstrapped and tested on x86_64-unknown-linux-gnu. Richard. 2017-11-28 Richard Biener PR middle-end/83141 * gimple-fold.c (gimple_fold_builtin_memory_op): For aggregate copies generated from memcpy use a character array as reference type. Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c (revision 255196) +++ gcc/gimple-fold.c (working copy) @@ -1039,8 +1039,24 @@ gimple_fold_builtin_memory_op (gimple_st gimple_set_vuse (new_stmt, gimple_vuse (stmt)); gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); } + new_stmt = gimple_build_assign (destvar, srcvar); + goto set_vop_and_replace; } - new_stmt = gimple_build_assign (destvar, srcvar); + + /* We get an aggregate copy. Use an unsigned char[] type to + perform the copying to preserve padding and to avoid any issues + with TREE_ADDRESSABLE types or float modes behavior on copying. */ + desttype = build_array_type_nelts (unsigned_char_type_node, + tree_to_uhwi (len)); + srctype = desttype; + if (src_align > TYPE_ALIGN (srctype)) + srctype = build_aligned_type (srctype, src_align); + if (dest_align > TYPE_ALIGN (desttype)) + desttype = build_aligned_type (desttype, dest_align); + new_stmt + = gimple_build_assign (fold_build2 (MEM_REF, desttype, dest, off0), + fold_build2 (MEM_REF, srctype, src, off0)); +set_vop_and_replace: gimple_set_vuse (new_stmt, gimple_vuse (stmt)); gimple_set_vdef (new_stmt, gimple_vdef (stmt)); if (gimple_vdef (new_stmt)