3 ms·
Will it do that without violating correctness? Are these necessary or unnecessary rules?
by nickpsecurity 10y ago
Will it do that without violating correctness? Are these necessary or unnecessary rules?
- AnimalMuppet 10y agoIf I understand correctly, it means that the math no longer fully conforms to every aspect of the IEEE spec. You lose some things like bits of precision in some operations, graceful underflow (where you keep as many bits as you can), and so on. These rules are unnecessary - for most problems. If you have a problem where you need them, though, your calculations will silently produce garbage without them. I think (but I am not sure) that most of the time, if you need full IEEE arithmetic for your problem, you know that you need it.
- nickpsecurity 10y agoBetween 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.
- Safety1stClyde 10y agoI've had extremely concerning test failures with -Ofast, disastrous calculation errors involving floating point numbers between 1 and 1,000.
- deleted 10y ago[deleted]
- ori_b 10y ago> Will it do that without violating correctness? No. It loses accuracy. That's why it's not on by default.