From: "Martin Liška" <mliska@suse.cz>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Marc Glisse <marc.glisse@inria.fr>
Subject: Re: [PATCH] Prefer mempcpy to memcpy on x86_64 target (PR middle-end/81657).
Date: Wed, 14 Mar 2018 13:10:00 -0000 [thread overview]
Message-ID: <79bacb3f-0665-bf77-b53e-08c3636189f1@suse.cz> (raw)
In-Reply-To: <CAMe9rOrG-L__+7TnwLcK4PVpVeFPKAfkgpNFxCT4ofFwd+9VKg@mail.gmail.com>
On 03/14/2018 01:57 PM, H.J. Lu wrote:
> On Wed, Mar 14, 2018 at 5:54 AM, Martin Liška <mliska@suse.cz> wrote:
>> On 03/13/2018 04:23 PM, Jakub Jelinek wrote:
>>> On Tue, Mar 13, 2018 at 04:19:21PM +0100, Martin Liška wrote:
>>>>> Yes, see e.g. TARGET_LIBC_HAS_FUNCTION target hook,
>>>>> where in particular linux_libc_has_function deals with various C libraries.
>>>>> Of course, in this case you need another target hook, that is dependent both
>>>>> on the target backend and C library.
>>>>>
>>>>> It would be nice to make the target hook a little bit more generic as well,
>>>>> e.g. pass it enum builtin_function and query if it is fast, slow or
>>>>> unknown, or even some kind of cost, where the caller could ask for cost of
>>>>> BUILT_IN_MEMCPY and BUILT_IN_MEMPCPY and decide based on the relative costs.
>>>>
>>>> Let me start with simple return enum value of FAST,SLOW,UNKNOWN. I've added new hook
>>>> definition to gcc/config/gnu-user.h that will point to gnu_libc_function_implementation.
>>>> I would like to implement the function in gcc/targhooks.c, but I don't know how to
>>>> make ifdef according to target?
>>>
>>> Put there just the default implementation (everything is UNKNOWN?).
>>>
>>>> One another issue is that built_in_function is enum defined in tree.h. Thus I'll replace the
>>>> callback argument with int, that will be casted. One last issue: am I right that I'll have to define
>>>> TARGET_LIBC_FUNCTION_IMPLEMENTATION in each config file (similar to no_c99_libc_has_function)?
>>>
>>> And define the i386/x86_64 glibc one in config/i386/*.h, check there
>>> OPTION_GLIBC and only in that case return something other than UNKNOWN.
>>>
>>> And redefine TARGET_LIBC_FUNCTION_IMPLEMENTATION only in that case.
>>>
>>> Jakub
>>>
>>
>> Hi.
>>
>> I'm sending V2 that can survive bootstrap and regression tests on both x86_64 and ppc64le.
>>
>> Martin
>
> diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c
> b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c
> index d82e2232d7b..91e1c87f83f 100644
> --- a/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c
> +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c
> @@ -62,7 +62,7 @@ main_test (void)
> mempcpy (p + 5, s3, 1);
> if (memcmp (p, "ABCDEFg", 8))
> abort ();
> - mempcpy (p + 6, s1 + 1, l1);
> + memcpy (p + 6, s1 + 1, l1);
> if (memcmp (p, "ABCDEF2", 8))
> abort ();
> }
>
> This is a mempcpy test. Why is mempcpy changed to memcpy?
>
Because this mempcpy is not optimized out to memcpy and it then aborts.
It's proper to leave here mempcpy I believe.
Martin
next prev parent reply other threads:[~2018-03-14 13:08 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 8:57 Martin Liška
2018-03-12 9:40 ` Marc Glisse
2018-03-13 8:25 ` Martin Liška
2018-03-13 8:35 ` Jakub Jelinek
2018-03-13 9:22 ` Richard Biener
2018-03-13 15:19 ` Martin Liška
2018-03-13 20:35 ` Jakub Jelinek
2018-03-14 12:57 ` Martin Liška
2018-03-14 13:08 ` H.J. Lu
2018-03-14 13:10 ` Martin Liška [this message]
2018-03-14 13:43 ` Jakub Jelinek
2018-03-14 13:08 ` Jakub Jelinek
2018-03-14 14:04 ` Martin Liška
2018-03-18 22:18 ` Martin Liška
2018-03-21 10:37 ` Jakub Jelinek
2018-03-28 14:29 ` Martin Liška
2018-03-28 14:35 ` Jakub Jelinek
2018-03-28 17:59 ` Martin Liška
2018-03-28 18:35 ` Jakub Jelinek
2018-03-29 12:14 ` Martin Liška
2018-03-29 12:31 ` H.J. Lu
2018-03-29 12:43 ` Jakub Jelinek
2018-03-29 12:35 ` Martin Liška
2018-04-04 10:13 ` Martin Liška
2018-04-09 12:31 ` Martin Liška
2018-04-10 10:35 ` Jakub Jelinek
2018-04-10 12:28 ` Martin Liška
2018-04-12 13:22 ` Martin Liška
2018-04-12 13:42 ` Jan Hubicka
2018-04-12 13:52 ` Richard Biener
2018-04-12 14:35 ` Jakub Jelinek
2018-04-12 14:19 ` Richard Biener
2018-04-12 14:35 ` Jakub Jelinek
2018-04-12 15:17 ` Richard Biener
2018-04-12 17:35 ` Jakub Jelinek
2018-04-12 16:03 ` Richard Biener
2018-07-05 19:34 ` Jeff Law
2018-03-12 10:08 ` Richard Biener
2018-03-12 13:35 ` Jakub Jelinek
2018-04-12 15:53 Wilco Dijkstra
2018-04-12 16:11 ` H.J. Lu
2018-04-12 16:35 ` Jakub Jelinek
2018-04-12 16:30 ` Wilco Dijkstra
2018-04-12 17:35 ` Jakub Jelinek
2018-04-12 17:29 ` Wilco Dijkstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=79bacb3f-0665-bf77-b53e-08c3636189f1@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
--cc=jakub@redhat.com \
--cc=marc.glisse@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).