From: James Antill <james@and.org>
To: linux-gcc@vger.kernel.org
Cc: libc-alpha@sources.redhat.com
Subject: Re: strcmp is too heavy for its everyday usage...
Date: Wed, 14 Jan 2004 00:09:18 -0500 [thread overview]
Message-ID: <m3vfnfxgjl.fsf@code.and.org> (raw)
In-Reply-To: <20040109081231.GA4218@twiddle.net> (Richard Henderson's message of "Fri, 9 Jan 2004 00:12:31 -0800")
Richard Henderson <rth@twiddle.net> writes:
> On Fri, Jan 09, 2004 at 10:11:45AM +0500, Denis Zaitsev wrote:
>> (r= a[0] - b[0]) &&
>> (r= a[1] - b[1]) &&
>> (r= a[2] - b[2]) &&
>> (r= a[3] - b[3]);
>> return r;
>> }
>>
>> never do that, as it's not asked to. Or this kind of optimization is
>> assumed ok for compiler, but just still unimplemented?
>
> Certainly it's ok if it converts.
>
> However, on most targets you'd have to know that a and b are aligned.
> Worse, even for targets like x86 that support unaligned loads you have
> to know for certain that neither a[3] nor b[3] could possibly segv
> when a[0] and b[0] won't. That condition is trivial when a and b are
> aligned, but otherwise...
Fair enough, but...
extern int
s(const unsigned char a[static 4], const unsigned char b[static 4])
{
int r;
(r= a[0] - b[0]) &&
(r= a[1] - b[1]) &&
(r= a[2] - b[2]) &&
(r= a[3] - b[3]);
return r;
}
...produces the same code.
--
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null
prev parent reply other threads:[~2004-01-14 5:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-08 1:09 strcmp is too heavy for its everyday usage Denis Zaitsev
2004-01-08 1:13 ` Roland McGrath
2004-01-08 1:36 ` Denis Zaitsev
2004-01-08 9:30 ` Andreas Schwab
2004-01-09 5:11 ` Denis Zaitsev
2004-01-09 8:12 ` Richard Henderson
2004-01-09 8:49 ` Denis Zaitsev
2004-01-14 5:09 ` James Antill [this message]
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=m3vfnfxgjl.fsf@code.and.org \
--to=james@and.org \
--cc=libc-alpha@sources.redhat.com \
--cc=linux-gcc@vger.kernel.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).