public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets
@ 2023-06-07 20:33 law at gcc dot gnu.org
  2023-06-09  6:52 ` [Bug rtl-optimization/110163] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: law at gcc dot gnu.org @ 2023-06-07 20:33 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/110163] [14 Regression] Comparing against a constant string is inefficient on some targets
  2023-06-07 20:33 [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets law at gcc dot gnu.org
@ 2023-06-09  6:52 ` rguenth at gcc dot gnu.org
  2023-06-09 14:49 ` law at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-09  6:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110163

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
   Target Milestone|---                         |14.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is marked as regression - was this really better in GCC 13?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/110163] [14 Regression] Comparing against a constant string is inefficient on some targets
  2023-06-07 20:33 [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets law at gcc dot gnu.org
  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
  3 siblings, 0 replies; 5+ messages in thread
From: law at gcc dot gnu.org @ 2023-06-09 14:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110163

--- Comment #2 from Jeffrey A. Law <law at gcc dot gnu.org> ---
It is a regression for rv64.  So probably P4 would be most appropriate.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/110163] [14 Regression] Comparing against a constant string is inefficient on some targets
  2023-06-07 20:33 [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets law at gcc dot gnu.org
  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
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-17 10:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110163

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/110163] [14/15 Regression] Comparing against a constant string is inefficient on some targets
  2023-06-07 20:33 [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets law at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-10-17 10:57 ` rguenth at gcc dot gnu.org
@ 2024-05-07  7:40 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110163

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |14.2

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-07  7:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 20:33 [Bug rtl-optimization/110163] New: [14 Regression] Comparing against a constant string is inefficient on some targets law at gcc dot gnu.org
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

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).