That can easily lead to excessive branch target buffer invalidation and mess up branch prediction.<p>It might look acceptable in microbenchmarks, with just 1-10% performance loss and be a total disaster in an actual running system.<p>A mispredicted branch costs about 15 clock cycles. You&#x27;ll have a lot of those when CPU can&#x27;t do bookkeeping on all of your range check branches anymore. The range checks themselves might run fast and fine, but those <i>other</i> branches your program has to execute can become pathological. Those, where the default choice for branches not present in CPU branch prediction buffer and branch target buffer is wrong.<p>15 clock cycles is rather excessive on any modern CPU that&#x27;s supposed to execute 1-4 instructions per clock cycle! In the worst pathological cases this can mean an order of magnitude (~10x) worse performance.<p>Of course data flow analysis might mitigate need for actual range checks, if the compiler can prove the value can never be out of range (of representable values with a given type).<p>Regardless it is important to understand worst case price can be very high, this type of behavior should not be default in any performance oriented language.