From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11842 invoked by alias); 29 Mar 2018 12:31:47 -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 10550 invoked by uid 89); 29 Mar 2018 12:31:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:fasynch 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; Thu, 29 Mar 2018 12:31:39 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C8CF9AFAC; Thu, 29 Mar 2018 12:31:36 +0000 (UTC) Subject: Re: [PATCH] Prefer mempcpy to memcpy on x86_64 target (PR middle-end/81657). To: Jakub Jelinek Cc: Richard Biener , Uros Bizjak , gcc-patches@gcc.gnu.org, Marc Glisse , "H.J. Lu" References: <20180313152359.GB8577@tucnak> <2cc467cb-569a-88be-0f91-b6f389415ffd@suse.cz> <20180314130754.GH8577@tucnak> <4ca9c192-84f2-95ba-ffd7-1c9aa9be1dfd@suse.cz> <20180321103425.GJ8577@tucnak> <20180328143114.GK8577@tucnak> <20180328163652.GL8577@tucnak> <772b1171-2321-67d9-85e7-358a5cad0efa@suse.cz> <20180329122532.GP8577@tucnak> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <17bbc039-e511-4fbe-d534-3d6d21aadc00@suse.cz> Date: Thu, 29 Mar 2018 12:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180329122532.GP8577@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg01539.txt.bz2 On 03/29/2018 02:25 PM, Jakub Jelinek wrote: > On Thu, Mar 29, 2018 at 01:28:13PM +0200, Martin Liška wrote: >> On 03/28/2018 06:36 PM, Jakub Jelinek wrote: >>> On Wed, Mar 28, 2018 at 06:30:21PM +0200, Martin Liška wrote: >>>> --- a/gcc/config/linux.c >>>> +++ b/gcc/config/linux.c >>>> @@ -37,3 +37,24 @@ linux_libc_has_function (enum function_class fn_class) >>>> return false; >>>> } >>>> + >>>> +/* This hook determines whether a function from libc has a fast implementation >>>> + FN is present at the runtime. We override it for i386 and glibc C library >>>> + as this combination provides fast implementation of mempcpy function. */ >>>> + >>>> +enum libc_speed >>>> +ix86_linux_libc_func_speed (int fn) >>> >>> Putting a ix86_ function into config/linux.c used by most linux targets is >>> weird. Either we multiple linux targets with mempcpy fast, then name it >>> somehow cpu neutral and let all those CPUs pick it up in config/*/linux.h. >>> And yes, we do care about i?86-linux. Or it is for x86 only, and then >>> it shouldn't be in config/linux.c, but either e.g. static inline in >>> config/i386/linux.h, or we need config/i386/linux.c if we don't have it >>> already. >> >> I'm fine with putting the implementation into gcc/config/i386/linux.c. Can you please > > Can't you just put it into gcc/config/i386/linux-common.h as static inline, > so that it is optimized away whenever not needed? I would like to put it there, but: g++ -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -I. -Ibuild -I../../gcc -I../../gcc/build -I../../gcc/../include -I../../gcc/../libcpp/include \ -o build/genpreds.o ../../gcc/genpreds.c In file included from ./tm.h:38:0, from ../../gcc/genpreds.c:26: ../../gcc/config/i386/linux-common.h: In function ‘libc_speed ix86_linux_libc_func_speed(int)’: ../../gcc/config/i386/linux-common.h:137:8: error: use of enum ‘built_in_function’ without previous declaration enum built_in_function f = (built_in_function)fn; ^~~~~~~~~~~~~~~~~ ../../gcc/config/i386/linux-common.h:137:31: error: ‘built_in_function’ was not declared in this scope enum built_in_function f = (built_in_function)fn; ^~~~~~~~~~~~~~~~~ ../../gcc/config/i386/linux-common.h:137:31: note: suggested alternative: ‘machine_function’ enum built_in_function f = (built_in_function)fn; ^~~~~~~~~~~~~~~~~ machine_function ../../gcc/config/i386/linux-common.h:144:12: error: ‘BUILT_IN_MEMPCPY’ was not declared in this scope case BUILT_IN_MEMPCPY: ^~~~~~~~~~~~~~~~ Martin > > If you really want to add a c file, it better not be called linux.c, because > linux.o for it would clash with linux.o from gcc/config/linux.c. And, > you'd need to add the whatever.o into extra_objs in gcc/config.gcc and add > rules for it into gcc/config/i386/t-linux (see linux.o in config.gcc and > config/t-linux). > >> help me how to conditionally build the file? > > Jakub >