News for hackers. Stuff that matters.
Re:Myths about Integer Overflow in Rust by vardump on Friday April 29, 2016 @07:53PM (#11599515)
To add, to avoid any misunderstanding: the cost is probably within 1-10% in likely scenarios on most real world code.

Pathological case would be code with a lot of taken branches mixed with range/overflow checks.

For range checks, any sane compiler would generate code that doesn't branch if the value is in range. If no branch predictor entry is present, branches are assumed [1] to be not taken. These branches can still thrash BTB (kind of cache trashing) and cause taken branches that fell out of BTB to become always mispredicted, thus very expensive.

[1]: Some architectures do support branch hints, even x86 did so in the past. Modern x86 CPUs simply ignore these hints.

Re:Myths about Integer Overflow in Rust by pcwalton on Friday April 29, 2016 @08:16PM (#11599612)
Not only that, you lose the ability to pattern match simple arithmetic to LEA and bloat your code size.