From: Jeff Law <jeffreyalaw@gmail.com>
To: Hamza Mahfooz <someguy@effective-light.com>, gcc-patches@gcc.gnu.org
Cc: Richard Biener <rguenther@suse.de>,
Jakub Jelinek <jakub@redhat.com>, Ian Lance Taylor <ian@airs.com>,
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>,
Aldy Hernandez <aldyh@redhat.com>,
Martin Sebor <msebor@gcc.gnu.org>
Subject: Re: [PATCH v2 1/2] strlen: fold strstr() even if the length isn't previously known [PR96601]
Date: Mon, 4 Sep 2023 23:14:41 -0600 [thread overview]
Message-ID: <e1c31c86-50cd-49a9-a320-91359c744fe9@gmail.com> (raw)
In-Reply-To: <20230904205814.222166-1-someguy@effective-light.com>
On 9/4/23 14:58, Hamza Mahfooz wrote:
> Currently, we give up in fold_strstr_to_strncmp() if the length of the
> the second argument to strstr() isn't known to us by the time we hit
> that function. However, we can instead insert a strlen() in ourselves
> and continue trying to fold strstr() into strlen()+strncmp().
>
> PR tree-optimization/96601
>
> gcc/ChangeLog:
>
> * tree-ssa-strlen.cc (fold_strstr_to_strncmp): If arg1_len == NULL,
> insert a strlen() for strstr()'s arg1 and use it as arg1_len.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/strlenopt-30.c: Modify test.
I'm not sure it's necessarily a win to convert to strncmp as
aggressively as this patch would do. Essentially when you have large
needles that are partially matched repeatedly, performance can
significantly suffer.
If we're going to seriously consider this path, then I'd like to see how
it performs in general. The glibc testsuite I think has some
performance coverage for strstr.
jeff
next prev parent reply other threads:[~2023-09-05 5:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 20:58 Hamza Mahfooz
2023-09-04 20:58 ` [PATCH v2 2/2] strlen: call handle_builtin_strlen() from fold_strstr_to_strncmp() Hamza Mahfooz
2023-09-05 5:14 ` Jeff Law [this message]
2023-09-05 9:04 ` [PATCH v2 1/2] strlen: fold strstr() even if the length isn't previously known [PR96601] Jakub Jelinek
2023-09-06 4:15 ` Hamza Mahfooz
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=e1c31c86-50cd-49a9-a320-91359c744fe9@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=aldyh@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ian@airs.com \
--cc=jakub@redhat.com \
--cc=msebor@gcc.gnu.org \
--cc=prathamesh.kulkarni@linaro.org \
--cc=rguenther@suse.de \
--cc=someguy@effective-light.com \
/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).