News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by msbarnett on Thursday May 20, 2021 @03:40PM (#27226088)
> Can you provide even one real-world example where this makes a difference, i.e. not some microbenchmark

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...

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.
Re:Undefined behavior in C is a reading error by msbarnett on Friday May 21, 2021 @04:41AM (#27231773)
The optimizations impacted by -fwrapv have nothing whatsoever to do with “leaving out error checks”
Re:Undefined behavior in C is a reading error by vyodaiken on Friday May 21, 2021 @03:43PM (#27238965)
I don't know how you can say that

z = x+y; if(z< x )overflowerror(); //important computation and

for(i=start, i >= start && i < n; i++)docomputation(x[i]); etc.