Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

why would an error checking branch ever be mispredicted. more to the point why would error checking or exceptions ever be in an optimized inner loop.


If they're rare enough that they are ~never mispredicted then why does the cost of exceptions matter when they do happen? If they are common, then they're going to be mispredicted.

The demo benchmark, for example, would produce basically always missed branches. Well, if would if the compiler didn't just strip the empty branch, invalidating the entire benchmark.


Because the branch prediction cache puns an error check with a loop predicate and some other random branch.

Branch predictors steadily get better, sure, but they're not infallible. Remember that reducing the total number of branches in a program helps the branch predictor predict better.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: