This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/84029] Partially inline strcmp


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

--- Comment #2 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> If we know the length of either argument and the other argument is properly
> aligned we can do a 2, 4 or 8 byte compare upfront.  Not sure how often that
> happens (esp. with regard to knowing alignment to make sure there's no
> page fault).

Yes that is another optimization related to PR78809 where you could do multiple
characters in one go when you know alignment (one of the strings must be a
constant string as otherwise equality doesn't work).

> Note this optimization has a code-size impact and thus should be done only
> for hot code regions, eventually based on a value-profile?

If codesize impact is significant it could be -O3 only. However there are not
that many uses of strcmp in most applications, so if the gain is large (think
naive code comparing an input string against a set of keywords like in
glibc/argp/argp-parse.c), it may be worth it with -O2.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]