Remix.run Logo
dzaima 5 months ago

The limiting thing isn't necessarily speculating, but more just the number of branches per cycle, i.e. number of non-contiguous locations the processor has to query from L1 / uop cache (and which the branch predictor has to determine the location of). You get that limit with unconditional branches too.

gpderetta 5 months ago | parent [-]

Indeed, the limit is on taken branches, hence why making the most likely case fall through is often an optimization.

adgjlsfhk1 5 months ago | parent [-]

The tricky part here is that compilers are pretty bad (without PGO at least) of knowing what side of the branch matters.