Branchless programming

#compsci #programming🖥️

Reducing if then statements in the loop. Sometimes using arithmetic operators instead.

https://dev.to/jobinrjohnson/branchless-programming-does-it-really-matter-20j4

Branching is when we split the flow of the program into two parts based on a runtime condition check. Consider the scenario of executing a simple if statement.

int main() {
    int a = 5;
    int b = 20;
    if (a < b) {
        a = 10;
    }
    return a;
}

In the above program, until the if statement is evaluated the program follows a single control path.

After executing the condition "a<b" the program is divided into two branches based on the expression evaluation result.