public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "law at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets Date: Wed, 07 Jun 2023 20:33:11 +0000 [thread overview] Message-ID: <bug-110163-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110163 Bug ID: 110163 Summary: [14 Regression] Comparing against a constant string is inefficient on some targets Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- Comparing against a constant string is expanded by inline_string_cmp and on some targets the generated code can be inefficient. This can be seen in spec2017's omnetpp benchmark, particularly when the inline string comparison limits are increased. The problem is the expansion code arranges to do all the arithmetic and tests in SImode. On RV64 this introduces a sign extension for each test due to how RV64 expresses 32bit ops. It would be better to do all the computations in word_mode, then convert the final result to SImode, at least for RV64 and likely for other targets. I experimented with starting to build out cost checks to determine what mode to use for the internal computations. That ran afoul of x86 where the cost of a byte load is different than the cost of an extended byte load, even though they use the exact same instruction. There's also a need to cost out the computations, test & branch in the different modes as well once the x86 hurdle is behind us. I've set work on this aside for now. But the discussion can be found in these two threads: https://gcc.gnu.org/pipermail/gcc-patches/2023-June/620601.html https://gcc.gnu.org/pipermail/gcc-patches/2023-June/620577.html #include <string.h> int foo (char *x) { return strcmp (x, "lowerLayout"); } Compiled with -O2 --param builtin-string-cmp-inline-length=100 on rv64 should show the issue.
next reply other threads:[~2023-06-07 20:33 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-07 20:33 law at gcc dot gnu.org [this message] 2023-06-09 6:52 ` [Bug rtl-optimization/110163] " rguenth at gcc dot gnu.org 2023-06-09 14:49 ` law at gcc dot gnu.org 2023-10-17 10:57 ` rguenth at gcc dot gnu.org 2024-05-07 7:40 ` [Bug rtl-optimization/110163] [14/15 " rguenth at gcc dot gnu.org
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-110163-4@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).