Reputation: 227
Modern CPUs since at least the 486 ¹) have a tightly-pipelined design, so conditional branches can cause "stalls" in which the pipeline has to be flushed and the code restarted on a different branch of the program. That's why it makes sense to avoid conditional branches by using branchless programming techniques on these modern CPUs.
But what about the older Processors like the 8086, 8088, 80286 and 80386, that had a loosely coupled (buffered) pipeline at best? Does branchless programming make any sense on them? Especially when the branchless version contains more instructions than the branched one?
¹) The 80486 does have a 5 stages pipeline and was the first x86 CPU that used a tightly-pipelined design.
Upvotes: 1
Views: 144