From: Alexey Dobriyan <adobriyan@gmail.com>
To: Willy Tarreau <w@1wt.eu>
Cc: lkp@intel.com, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: tools/nolibc: fix missing strlen() definition and infinite loop with gcc-12
Date: Sun, 9 Oct 2022 18:45:49 +0300 [thread overview]
Message-ID: <Y0LsreRGq3nbe2xC@localhost.localdomain> (raw)
Willy Tarreau wrote:
> +#if defined(__GNUC__) && (__GNUC__ >= 12)
> +__attribute__((optimize("no-tree-loop-distribute-patterns")))
> +#endif
> static __attribute__((unused))
> -size_t nolibc_strlen(const char *str
I'd suggest to use asm("") in the loop body. It worked in the past
to prevent folding division loop back into division instruction.
Or switch to
size_t f(const char *s)
{
const char *s0 = s;
while (*s++)
;
return s - s0 - 1;
}
which compiles to 1 branch, not 2.
But of course they could recognise this pattern too.
next reply other threads:[~2022-10-09 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 15:45 Alexey Dobriyan [this message]
2022-10-09 17:59 ` tools/nolibc: fix missing strlen() definition and infinite loop with gcc-12 Willy Tarreau
2022-10-09 18:36 ` Willy Tarreau
2022-10-10 10:03 ` David Laight
2022-10-11 6:20 ` Willy Tarreau
2022-10-11 10:18 ` David Laight
-- strict thread matches above, loose matches on Subject: below --
2022-10-09 15:19 Willy Tarreau
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=Y0LsreRGq3nbe2xC@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lkp@intel.com \
--cc=paulmck@kernel.org \
--cc=w@1wt.eu \
/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