Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!.POSTED!not-for-mail From: Willem Newsgroups: comp.lang.c Subject: Re: Short-circuiting in C Date: Fri, 27 May 2011 16:08:07 +0000 (UTC) Organization: Stack Usenet News Service Lines: 32 Message-ID: References: <5d853059-e0c5-4ef1-b758-f56a02355c22@p23g2000vbl.googlegroups.com> NNTP-Posting-Host: toad.stack.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: mud.stack.nl 1306512487 14263 2001:610:1108:5010::135 (27 May 2011 16:08:07 GMT) X-Complaints-To: abuse@stack.nl NNTP-Posting-Date: Fri, 27 May 2011 16:08:07 +0000 (UTC) User-Agent: slrn/0.9.9p1 (FreeBSD) Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:4881 ImpalerCore wrote: ) On May 26, 1:58?pm, Billy Mays wrote: )> I was wondering if there is a way to avoid the C short circuiting for )> boolean expressions such as the following: )> )> if(a && b && c) { )> ? ? ?/* Do stuff */ )> )> } )> )> I am currently doing GPU programming and it would be better to evaluate )> the entire condition, even if a is 0, since branches are slow. ) ) Not sure if it would work, but what about evaluating the condition ) outside of the 'if' statement? ) ) bool my_condition_is_true = a && b && c; ) if (my_condition_is_true) { ) /* Do stuff */ ) } Nope, that would make the exact same branches. I wouldn't be surprised if it generated exactly the same opcodes, even. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT