Re:Undefined behavior in C is a reading error
by vyodaiken on Thursday May 20, 2021 @10:14PM
(#27229795)
Sure, if you leave out error checks code runs faster. Compile mutexes to no-ops and get an even better speedup.
Sure. I don't even have to leave this thread to find one: https://news.ycombinator.com/item?id=27223954 reports a measurable speed impact to PostgreSQL when compiled with -fwrapv, which rules out the exact optimization in question.
This shouldn't be surprising; loops are extremely common and superscalar processors benefit enormously from almost anything other than a naïve translation of them.
Here's -fwrapv cutting performance of a function in half in Cython vs the non-fwrapv compilation: https://stackoverflow.com/questions/46496295/poor-performanc...