If you are writing some SIMD code that will be run by another program, is it always favorable to get rid of branching to increase performance? I heard that even doing extra operations just to avoid if/else
statements, etc is still much faster.
I ask this because I have some branching that I do that's basically like this:
// axis; x=0, y=1, z=2
float p, q;
if (axis == 0)
{
p = point.y;
q = point.z;
}
else if (axis == 1)
{
p = point.x;
q = point.z;
}
else if (axis == 2)
{
p = point.x;
q = point.y;
}
Can I avoid this kind of branching with some clever trick?