visual c++ branching and optimization question?
I have a couple of questions regarding optimization of c++ code for visual c++ (2010) for intel platform having to do with IF's and branches.
If I have the statement
int x = (someBooleanCondition) ? 1 : 0;
Does the compiler/intel make use of a conditional load instruction or does it do a series of branches to make the correct assignment? I know branches are inefficient and I've done work on DSPs that have a conditional load instruction to help avoid them, but I don't know if the pentium or visual c++ have/use them.
The next question is if I have something like
if(someBooleanCondition) {
// code that is not normally run. maybe <1% of the time this condition is true
}
What is the optimum way to structure this so that 99+ % of the time it will not do any branches. Essentially, I'd want it to test the condition, then branch if the condition is true to some other place in the code, then branch back after those statements are executed.
Will it only do that if I have a procedure call? Sometimes I'd like to have access to local variables in there and don't want to go through the hassle of putting in the overhead for a procedure call.