I'm pretty sure the following optimization is invalid, since a is not a bool array, but one of positive/negative numbers (see top of article):
> You can use arithmetics to go branchless.
if (a[i] > 0) {
cnt++;
}
> Rewriting using arithmetic takes advantage of the fact that the expression a[i] > 0 has an arithmetic value 1 if true and 0 if false. So the whole expression can be rewritten as:
> You can use arithmetics to go branchless.
> Rewriting using arithmetic takes advantage of the fact that the expression a[i] > 0 has an arithmetic value 1 if true and 0 if false. So the whole expression can be rewritten as: