Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Short-circuiting in C
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Willem, post: 4214857"] ImpalerCore 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 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Short-circuiting in C
Top