2 ms·
Between you and ori_b, it sounds like proponents of undefined behavior optimization should distinguish between better optimization that's correct and possibly i
by nickpsecurity 10y ago
Between you and ori_b, it sounds like proponents of undefined behavior optimization should distinguish between better optimization that's correct and possibly incorrect. I don't care how much faster it will go if it breaks my program or corrupts my data in subtle ways. However, if I didn't care for specific computations, then it would be good to know there were such optimizations available.
- ori_b 10y agoThis isn't about undefined behavior. It's about ignoring the way that floating point math works like real numbers. That lets you assume things like addition are commutative, which enables things like loop invariant code motion, reordering of operations, and generally doing
- nickpsecurity 10y agoThe parent of my original comment gave it as an example of undefined behavior improving performance. I don't know enough to say whether that's true or not but was responding to correctness issues in that. So, now you're saying that the floating point optimizations sacrificing accuracy don't use any undefined behavior? That the parent just gave a bad example?
- ori_b 10y agoI'm saying that it violates the spec if you enable it. It's not undefined behavior in the spec. If you want a good example of undefined behavior enabling optimizations, you can eliminate loop bounds checks by assuming that integers will never overflow.
- nickpsecurity 10y agoGotcha. Thanks.