From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35272 invoked by alias); 23 Feb 2016 10:25:26 -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 35206 invoked by uid 89); 23 Feb 2016 10:25:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=honza, xxx, ultimate X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 23 Feb 2016 10:25:19 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 5CE815430FD; Tue, 23 Feb 2016 11:25:15 +0100 (CET) Date: Tue, 23 Feb 2016 10:25:00 -0000 From: Jan Hubicka To: Richard Biener Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org, Jan Hubicka Subject: Re: [PATCH] Fix PR56888 Message-ID: <20160223102515.GB43696@kam.mff.cuni.cz> References: <20160222125418.GI3017@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2016-02/txt/msg01556.txt.bz2 > On Mon, 22 Feb 2016, Jakub Jelinek wrote: > > > On Mon, Feb 22, 2016 at 01:44:09PM +0100, Richard Biener wrote: > > > --- 1079,1086 ---- > > > || !dominated_by_p (CDI_DOMINATORS, > > > loop->latch, gimple_bb (stmt))) > > > return; > > > + if (cgraph_node::get (cfun->decl)->aliases (BUILT_IN_MEMSET)) > > > + return; > > > > Perhaps also punt here for: > > BUILT_IN_MEMSET_CHK > > BUILT_IN_TM_MEMSET > > BUILT_IN_BZERO > > ? > > > > > partition->kind = PKIND_MEMSET; > > > partition->main_dr = single_store; > > > partition->niter = nb_iter; > > > *************** classify_partition (loop_p loop, struct > > > *** 1135,1140 **** > > > --- 1138,1146 ---- > > > } > > > free_dependence_relation (ddr); > > > loops.release (); > > > + if (cgraph_node::get (cfun->decl)->aliases (BUILT_IN_MEMCPY) > > > + || cgraph_node::get (cfun->decl)->aliases (BUILT_IN_MEMMOVE)) > > > + return; > > > > And here for > > BUILT_IN_MEMCPY_CHK > > BUILT_IN_TM_MEMCPY > > BUILT_IN_TM_MEMCPY_RNWT > > BUILT_IN_TM_MEMCPY_RTWN > > BUILT_IN_MEMPCPY > > BUILT_IN_MEMPCPY_CHK > > BUILT_IN_MEMMOVE_CHK > > BUILT_IN_TM_MEMMOVE > > BUILT_IN_BCOPY > > ? > > I'm going to wait for Honzas feedback. Testing all of the above > looks expensive - if those are implemented in terms of memcpy/memset > then hopefully in libc itself which hopefully always does local > calls. Well, other problem will be if memcpy itself is implemented by calling a function that does the actual copying job (for example, for large block sizes or so). So for ultimate QOI fix you really want to check if the function you are optimizing is reachable from any of those bultins. This is of course doable by means of simple propagation pass, but I am not sure if it makes sense to get that far. The checks however should not be that bad - they are done only when we recognize the memcpy pattern and want to optimize it and that is not too common case, right? > > It's not going to be an exhaustive check anyway, just a QOI one > covering those cases we've seen in the wild. Esp. as indirection > will break the detection (so does using asm(".alias XXX") which glibc > does). To lookup definition of the bulitin, you don't really need assembler name lookup. Just get cgraph node for the builtin decl and look next_sharing_asm_name and prev_shaing_asm_name lists (this works only when asm name hash is initialized, so to be sure just call symtab->symtab_initialize_asm_name_hash (); For next stage1 I have queued patch that makes duplicated decls to be transparent alises, so you will need to only lookup the ultimate alias target. I did not commited it to mainline becuase it requires lto-symtab like linking to be done each time new duplciate is inserted into the symbol table and it tends to find new user errors on misuse of asm("...") constructs. Also one needs to fix the chkp issues.... Honza > > Richard.