From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hopwood Subject: Re: code question? Date: Thu, 11 Aug 2005 19:53:06 +0100 Message-ID: <42FB9E92.1090509@blueyonder.co.uk> References: <1123775716.3043.15.camel@thinkpad> Reply-To: david.nospam.hopwood@blueyonder.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Keir Fraser wrote: > On 11 Aug 2005, at 18:03, M.A. Williamson wrote: > >> I think that: >> !!a & !b === (a != 0 ) && ( b == 0 ) >> >> It's just more efficient to do it directly using bitwise ops than to >> use the full logical operators (can gcc really not optimise this sort >> of thing???). > > It can't optimise out short-circuit semantics. Yes it can, if the second branch of the short-circuit is guaranteed to terminate with no side effects when it has defined behaviour. The function thread_jump in attempts to prove that a basic block satisfies this property, although I'm not sure whether gcc is capable of doing the specific optimization we're talking about here. I know that some other C compilers are. -- David Hopwood