public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit 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: Thu, 14 Jul 2022 21:10:52 +0000 [thread overview] Message-ID: <bug-103798-4-dx7Dz7bSON@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 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>: https://gcc.gnu.org/g:c6cf555a88f8ffb8ec85c2b94fe656ab217260ea commit r13-1699-gc6cf555a88f8ffb8ec85c2b94fe656ab217260ea Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Jun 17 07:33:06 2022 -0700 Simplify memchr with small constant strings When memchr is applied on a constant string of no more than the bytes of a word, simplify memchr by checking each byte in the constant string. int f (int a) { return __builtin_memchr ("AE", a, 2) != 0; } is simplified to int f (int a) { return ((char) a == 'A' || (char) a == 'E') != 0; } gcc/ PR tree-optimization/103798 * tree-ssa-forwprop.cc: Include "tree-ssa-strlen.h". (simplify_builtin_call): Inline memchr with constant strings of no more than the bytes of a word. * tree-ssa-strlen.cc (use_in_zero_equality): Make it global. * tree-ssa-strlen.h (use_in_zero_equality): New. gcc/testsuite/ PR tree-optimization/103798 * c-c++-common/pr103798-1.c: New test. * c-c++-common/pr103798-2.c: Likewise. * c-c++-common/pr103798-3.c: Likewise. * c-c++-common/pr103798-4.c: Likewise. * c-c++-common/pr103798-5.c: Likewise. * c-c++-common/pr103798-6.c: Likewise. * c-c++-common/pr103798-7.c: Likewise. * c-c++-common/pr103798-8.c: Likewise. * c-c++-common/pr103798-9.c: Likewise. * c-c++-common/pr103798-10.c: Likewise.
next prev parent reply other threads:[~2022-07-14 21:10 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 ` [Bug tree-optimization/103798] memchr with a (small) constant string should be expanded inline pinskia at gcc dot gnu.org 2022-06-16 17:37 ` hjl.tools at gmail dot com 2022-07-14 21:10 ` cvs-commit at gcc dot gnu.org [this message] 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-dx7Dz7bSON@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).