What techniques to avoid conditional branching do you know?

前端 未结 9 509
迷失自我
迷失自我 2021-02-03 23:47

Sometimes a loop where the CPU spends most of the time has some branch prediction miss (misprediction) very often (near .5 probability.) I\'ve seen a few techniques on very isol

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 00:11

    This level of optimization is unlikely to make a worthwhile difference in all but the hottest of hotspots. Assuming it does (without proving it in a specific case) is a form of guessing, and the first rule of optimization is don't act on guesses.

提交回复
热议问题