On 5/15/19 5:35 AM, Martin Liška wrote:
> On 5/14/19 5:07 PM, Martin Sebor wrote:
>> On 5/14/19 8:55 AM, Martin Liška wrote:
>>> On 5/13/19 3:07 PM, Jakub Jelinek wrote:
>>>> On Mon, May 13, 2019 at 12:14:37PM +0200, Martin Liška wrote:
>>>>> On 5/10/19 11:21 AM, Jakub Jelinek wrote:
>>>>>> On Fri, May 10, 2019 at 11:04:12AM +0200, Martin Liška wrote:
>>>>>>> --- a/gcc/config/i386/i386.h
>>>>>>> +++ b/gcc/config/i386/i386.h
>>>>>>> @@ -1906,6 +1906,9 @@ typedef struct ix86_args {
>>>>>>> #define CLEAR_RATIO(speed) ((speed) ? MIN (6,
>>>>>>> ix86_cost->move_ratio) : 2)
>>>>>>> +/* C library provides fast implementation of mempcpy function. */
>>>>>>> +#define TARGET_HAS_FAST_MEMPCPY_ROUTINE 1
>>>>>>> +
>>>>>> 1) we shouldn't be adding further target macros, but target hooks
>>>>> Done.
>>>>>
>>>>>> 2) I don't think this is a property of the x86 target, but of x86 glibc,
>>>>>> so you should set it on x86 glibc only (i.e. i?86/x86_64 linux and
>>>>>> hurd
>>>>>> when using glibc, not newlib, nor bionic/android, nor uclibc, nor
>>>>>> musl)
>>>>> I've implemented the in i386.c with DEFAULT_LIBC == LIBC_GLIBC. Hope it's
>>>>> correct?
>>>> No, that would be correct only in the rare SINGLE_LIBC configurations.
>>>> Either you can do
>>>> #ifdef OPTION_GLIBC
>>>> return OPTION_GLIBC;
>>>> #else
>>>> return false;
>>>> #endif
>>>> or define something in config/linux.h (or .[ch]) that you can then use in
>>>> i386.c.
>>>>
>>>> Jakub
>>>>
>>> Hi.
>>>
>>> You always have nice ideas. I'm sending updated patch which addresses both
>>> Jakub's
>>> and Wilco's comments.
>>>
>> index 66cee075018..7bff5cbd313 100644
>> --- a/gcc/target.def
>> +++ b/gcc/target.def
>> @@ -5797,6 +5797,12 @@ DEFHOOK
>> const char *, (void),
>> hook_constcharptr_void_null)
>>
>> +DEFHOOK
>> +(has_fast_mempcpy_routine,
>> + "Return true if a target has a fast mempcpy routine.",
>> + bool, (void),
>> + hook_bool_void_false)
>> +
>>
>> Not to be too nit-picky about the name but target.def refers to
>> functions rather than routines. It also defines a hook called
>> libc_has_function with the obvious semantics so if there's
>> a chance that it could be useful to query whether another libc
>> function is "fast" I would suggest to consider defining the hook
>> correspondingly, i.e.,
>>
>> bool libc_has_fast_function (enum function_class)
>>
>> and naming the macro similarly.
>>
>> Martin
> Hi Martin.
>
> That's a very good suggestion and I'm implementing that!
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Thanks,
> Martin
>
>
> 0001-Come-up-with-hook-libc_has_fast_function-PR-middle-e.patch
>
> From f865ba74008acc651e9ef2fbfc9f2d4bb9ce8fb8 Mon Sep 17 00:00:00 2001
> From: marxin <mli...@suse.cz>
> Date: Mon, 29 Apr 2019 13:46:25 +0200
> Subject: [PATCH] Come up with hook libc_has_fast_function (PR
> middle-end/90263).
>
> gcc/ChangeLog:
>
> 2019-05-15 Martin Liska <mli...@suse.cz>
>
> PR middle-end/90263
> * builtins.c (expand_builtin_memory_copy_args): When having a
> target with fast mempcpy implementation do now use memcpy.
> * config/i386/i386.c (ix86_libc_has_fast_function): New.
> (TARGET_LIBC_HAS_FAST_FUNCTION): Likewise.
> * doc/tm.texi: Likewise.
> * doc/tm.texi.in: Likewise.
> * target.def:
> * expr.c (emit_block_move_hints): Add 2 new arguments.
> * expr.h (emit_block_move_hints): Bail out when libcall
> to memcpy would be used.
>
> gcc/testsuite/ChangeLog:
>
> 2019-05-15 Martin Liska <mli...@suse.cz>
>
> PR middle-end/90263
> * gcc.c-torture/compile/pr90263.c: New test.
> * lib/target-supports.exp: Add check_effective_target_glibc.
> ---
> gcc/builtins.c | 17 +++++++++++++++--
> gcc/config/i386/i386.c | 15 +++++++++++++++
> gcc/doc/tm.texi | 5 +++++
> gcc/doc/tm.texi.in | 2 ++
> gcc/expr.c | 13 ++++++++++++-
> gcc/expr.h | 4 +++-
> gcc/target.def | 7 +++++++
> gcc/testsuite/gcc.c-torture/compile/pr90263.c | 10 ++++++++++
> gcc/testsuite/lib/target-supports.exp | 11 +++++++++++
> 9 files changed, 80 insertions(+), 4 deletions(-)
> create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr90263.c
>
OK
jeff