public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103798] memchr with a (small) constant string should be expanded inline. Date: Wed, 22 Dec 2021 07:24:32 +0000 [thread overview] Message-ID: <bug-103798-4-SiL855cfcx@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103798-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103798 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|libstdc++ |tree-optimization Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Severity|normal |enhancement Summary|Missed optimization: |memchr with a (small) |char_traits<char>::find |constant string should be |(and thus |expanded inline. |string_view::find_first_of) | |is slow when invoked with | |short strings | Last reconfirmed| |2021-12-22 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Really the issue is: _8 = __builtin_memchr ("eE", _7, 2); if (_8 != 0B) Should just be expanded to _7 == 'e' || _7 == 'E' . That is: int f(char a) { return __builtin_memchr ("e", a, 1) != 0; } int f1(char a) { return a == 'e'; } int g(char a) { return __builtin_memchr ("eE", a, 2) != 0; } int g1(char a) { return a == 'e' || a == 'E'; } f and f1 should produce the same assembly and g and g1 should produce the same (similar) assembly.
next prev parent reply other threads:[~2021-12-22 7:24 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-22 7:03 [Bug libstdc++/103798] New: Missed optimization: char_traits<char>::find (and thus string_view::find_first_of) is slow when invoked with short strings zhaoweiliew at gmail dot com 2021-12-22 7:24 ` pinskia at gcc dot gnu.org [this message] 2022-06-16 17:37 ` [Bug tree-optimization/103798] memchr with a (small) constant string should be expanded inline hjl.tools at gmail dot com 2022-07-14 21:10 ` cvs-commit at gcc dot gnu.org 2022-08-28 7:42 ` jbglaw@lug-owl.de
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=bug-103798-4-SiL855cfcx@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.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: linkBe 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).