bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: Use logical rather than bitwise operators on bools


From: Eric Blake
Subject: Re: [PATCH] maint: Use logical rather than bitwise operators on bools
Date: Wed, 23 Sep 2009 21:02:43 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Paul Eggert <eggert <at> CS.UCLA.EDU> writes:

> Furthermore, bitwise operators often generate shorter and faster code,
> particularly on modern processors where conditional branches are far
> more expensive than logical operations.  For example, consider these
> functions:
> 
> bool F (bool a, bool b, bool c, bool d) { return a && b && c && d; }
> bool G (bool a, bool b, bool c, bool d) { return a & b & c & d; }

Are we feeding these as bug reports to the gcc folks?  This seems like 
something they should be aware of, in that if there are no side effects in 
evaluating the four boolean variables, the compiler should be generating 
identical code for either choice of operator.  If we can get the compiler 
fixed, then I'd lean towards using && notation.

-- 
Eric Blake







reply via email to

[Prev in Thread] Current Thread [Next in Thread]