From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Subject: Re: [PATCH v2] wcrtomb: Make behavior POSIX compliant
Date: Mon, 9 May 2022 19:05:08 +0530 [thread overview]
Message-ID: <c154fe79-57b9-f19c-b592-17eb3170af1e@gotplt.org> (raw)
In-Reply-To: <1eba6382-8db1-d269-2ed1-a2c408e5be33@linaro.org>
On 09/05/2022 18:52, Adhemerval Zanella via Libc-alpha wrote:
>
>
> On 06/05/2022 11:04, Siddhesh Poyarekar via Libc-alpha wrote:
>
>> +
>> + if (__glibc_likely (result < 2))
>> + *s = *buf;
>> + else if (__glibc_likely (result == 2))
>> + memcpy (s, buf, result); /* Help the compiler. */
>> + else
>> + memcpy (s, buf, result);
>> + }
>> + }
>
> I am not following how this help the compiler here, it just duplicates the
> same memcpy call.
>
It should be able to inline the first memcpy call into a copy
instruction sequence. With just an `else`, result may be 2 or more, so
the compiler doesn't have enough information to do any inlining.
However, it just occurred to me that maybe something like this:
if (result <= MB_LEN_MAX)
memcpy (s, buf, result);
else
__builtin_unreachable ();
will likely produce an always avoid the memcpy call and generate an
inlined sequence. I'll test that and repost. Thanks for making me
think about this a bit more.
I'll also update the manual based on the discussion in the weekly call
to make the blurb more backport-friendly.
Thanks,
Siddhesh
next prev parent reply other threads:[~2022-05-09 13:35 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 6:26 [RFC] _FORTIFY_SOURCE strictness Siddhesh Poyarekar
2022-04-07 10:16 ` Andreas Schwab
2022-04-08 3:24 ` Siddhesh Poyarekar
2022-04-08 2:26 ` Paul Eggert
2022-04-08 3:32 ` Siddhesh Poyarekar
2022-04-08 5:37 ` Florian Weimer
2022-04-08 6:02 ` Siddhesh Poyarekar
2022-04-08 21:07 ` Paul Eggert
2022-04-11 8:02 ` Siddhesh Poyarekar
2022-05-05 18:43 ` [PATCH 0/2] More compliant wcrtomb Siddhesh Poyarekar
2022-05-05 18:43 ` [PATCH 1/2] benchtests: Add wcrtomb microbenchmark Siddhesh Poyarekar
2022-05-06 9:10 ` Florian Weimer
2022-05-06 12:49 ` [committed] " Siddhesh Poyarekar
2022-05-06 12:50 ` [PATCH 1/2] " Adhemerval Zanella
2022-05-06 12:59 ` Siddhesh Poyarekar
2022-05-06 13:20 ` Adhemerval Zanella
2022-05-06 13:26 ` Siddhesh Poyarekar
2022-05-06 13:36 ` Siddhesh Poyarekar
2022-05-06 13:46 ` Adhemerval Zanella
2022-05-05 18:43 ` [PATCH 2/2] wcrtomb: Make behavior POSIX compliant Siddhesh Poyarekar
2022-05-06 9:25 ` Paul Eggert
2022-05-06 13:40 ` Adhemerval Zanella
2022-05-06 13:46 ` Siddhesh Poyarekar
2022-05-06 14:04 ` [PATCH v2] " Siddhesh Poyarekar
2022-05-09 13:22 ` Adhemerval Zanella
2022-05-09 13:35 ` Siddhesh Poyarekar [this message]
2022-05-12 13:15 ` [PATCH v3] " Siddhesh Poyarekar
2022-05-13 4:56 ` Paul Eggert
2022-05-13 5:28 ` Paul Eggert
2022-05-13 11:31 ` Siddhesh Poyarekar
2022-05-13 11:38 ` Florian Weimer
2022-05-13 11:51 ` Siddhesh Poyarekar
2022-05-13 12:55 ` Florian Weimer
2022-05-13 12:30 ` Adhemerval Zanella
2022-05-13 13:42 ` Siddhesh Poyarekar
2022-05-13 17:58 ` Paul Eggert
2022-05-13 13:45 ` [committed] " Siddhesh Poyarekar
2022-05-13 8:18 ` [PATCH v3] " Siddhesh Poyarekar
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=c154fe79-57b9-f19c-b592-17eb3170af1e@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/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).