Comment

Comment by josephg

You've got it the wrong way around. If the branch predictor was 100% accurate, branchless code would have no performance benefit compared to branching code.

> X86 should support no-branch-predict-if

It almost does. You can use __builtin_expect to hint if the branch is predictable - like assertions. Don't annotate conditionals if they're truly unpredictable. The branch predictor will run, but it's not expensive.

parent josephg 18 hours ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton