From: Werner Almesberger <wa@almesberger.net>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Norbert Kiesel <nkiesel@tbdnetworks.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Multiple & vs. && and | vs. || bugs in 2.4.20
Date: Sun, 2 Mar 2003 18:41:14 -0300 [thread overview]
Message-ID: <20030302184114.Q2791@almesberger.net> (raw)
In-Reply-To: <3E6247F7.8060301@redhat.com>; from drepper@redhat.com on Sun, Mar 02, 2003 at 10:05:43AM -0800
Ulrich Drepper wrote:
> > - if (!urb->status & !acm->throttle) {
> > + if (!urb->status && !acm->throttle) {
[...]
> Have you really looked at detail at all these cases? The problem is
> that you have made the code less efficient on some platforms. The use
> of && requires shortcut evaluation. I.e., the compiler is forced to not
While I agree with your observation in general, this is actually
something the compiler should be able to figure out by itself:
- there's only a side-effect if acm is NULL
- in ACM_READY, we've already tested acm for NULL, and subsequently
de-referenced it
- acm is a local variable, and not aliased, so the dbg() can't
change it
So, given the negations, || and | are equivalent in this case, and
whether a jump, conditional execution, a bit operation, or something
else yields better code is compiler, machine, and context specific.
- Werner
--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
next prev parent reply other threads:[~2003-03-02 21:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-02 12:14 [PATCH] Multiple & vs. && and | vs. || bugs in 2.4.20 Norbert Kiesel
2003-03-02 18:05 ` Ulrich Drepper
2003-03-02 18:25 ` Roman Zippel
2003-03-02 21:41 ` Werner Almesberger [this message]
2003-03-02 22:03 ` Richard Henderson
2003-03-03 2:03 ` Norbert Kiesel
2003-03-03 3:02 ` John Levon
2003-03-06 19:58 ` Pavel Machek
2003-03-07 18:45 ` Norbert Kiesel
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=20030302184114.Q2791@almesberger.net \
--to=wa@almesberger.net \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nkiesel@tbdnetworks.com \
/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