lkml.org 
[lkml]   [2003]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Multiple & vs. && and | vs. || bugs in 2.4.20
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/____________________________________________/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:33    [from the cache]
©2003-2011 Jasper Spaans