Hello I hope I'm asking this in the right community, please feel free to redirect me some better place if you don't think it fits here.
As I learned when I went to university half an eternity ago, modern CPUs typically have large pipelines for instructions to gain performance by being able to do many simple things in parallell.
// A typical code block inside a loop that I fear would clog up a pipeline.
if(l1) a = ...;
elseif(l2) a = ...;
...
else a = ...;
// A different way to write it as a sum that would avoid
// branching but at a possible cost of more instructions (?)
a = (!!l1)*... + (!!l2)*... + ()*...;
Would modern compilers know how to (and allow themselves to) avoid branching in the first case or should I as an implementer put effort into helping the compiler by planning and rewriting my code as logical arithmetic expressions?
My goal is optimization for speed for number-crunching applications.