public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "antoshkka at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109931] Knowledge on literal not used in optimization
Date: Mon, 22 May 2023 12:57:40 +0000 [thread overview]
Message-ID: <bug-109931-4-G9waird1uf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109931-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109931
--- Comment #3 from Antony Polukhin <antoshkka at gmail dot com> ---
> But that's because nothing in the function asserts this? Without fully
> specializing and unrolling on the constant "hello" argument at least.
Yes, I was hoping for that unrolling to happen
Probably a more simplified case:
constexpr bool EqualICase(const char* lowercase, const char* y) noexcept {
for (;;) {
const auto lowercase_c = *lowercase;
if (!lowercase_c) return true;
if (lowercase_c != *y) {
return false;
}
++lowercase;
++y;
}
}
bool test2(const char* y) {
return EqualICase("he", y);
}
With range info for loads from read-only constants I'd expect this to become
just a
test2(char const*):
cmp BYTE PTR [rdi], 104
jne .L3
cmp BYTE PTR [rdi+1], 101
sete al
ret
.L3:
xor eax, eax
ret
rather than a fair loop with checks for \0
Godbolt: https://godbolt.org/z/z6rTYEzWx
next prev parent reply other threads:[~2023-05-22 12:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-22 12:33 [Bug tree-optimization/109931] New: " antoshkka at gmail dot com
2023-05-22 12:37 ` [Bug tree-optimization/109931] " rguenth at gcc dot gnu.org
2023-05-22 12:38 ` jakub at gcc dot gnu.org
2023-05-22 12:57 ` antoshkka at gmail dot com [this message]
2023-05-22 14:53 ` pinskia 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-109931-4-G9waird1uf@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: 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).