News for hackers. Stuff that matters.
Re:Null Pointer Dereferencing Causes Undefined Behavior by ufo on Monday April 20, 2015 @08:40PM (#9411702)
Just wondering: how much do these particular optimizations end up being worth in the end? Is it something noticeable or is it like array bounds checking where its almost always OK to leave the checks in the end?
Re:Null Pointer Dereferencing Causes Undefined Behavior by joosters on Monday April 20, 2015 @09:18PM (#9411794)
It's impossible to give a general answer. You could have a tight loop in a performance critical part of your code, where optimising out the NULL check removes (say) 25% of the loop code. Or, the check might be negligible. It depends upon the code.

That's why IMO people saying that the compiler shouldn't bother with these 'excessive' optimisations are wrong. It might be worthless for them and their programs, but might be valuable for others. Don't force your priorities upon other people.

Re:Null Pointer Dereferencing Causes Undefined Behavior by pcwalton on Monday April 20, 2015 @09:43PM (#9411857)
Yes. I'd also add that loop optimizations tend to magnify in importance when you consider that the loop might be vectorized. Especially since the state of scatter/gather SIMD intrinsics is so poor at the moment...