Hacker News new | ask | show | jobs
by 35bge57dtjku 3176 days ago
> On their own, % and / are way slower than +, -, *, <<, >>.

And the branch instruction is free??

1 comments

More or less, assuming you can predict it. But there's a penalty for misprediction. So it boils down to whether using % frequently (either as a native instruction or as a sequence of instructions) is more or less expensive than predicting a branch frequently, given a certain misprediction rate.
> More or less, assuming you can predict it. But there's a penalty for misprediction.

Yeah, no, that's not free.

Ok, so what changes would you make to my explanations?