Re:Why does changing 0.1f to 0 slow down performance by 10x?
by tlb on Sunday March 11, 2012 @03:01PM
(#3690970)
The semantics of floating point arithmetic in C do not allow the first line to be eliminated. It has non-trivial behavior in the case of signaling NaNs or denormals or -0.0.
[ Parent
| on HN ]
Re:Why does changing 0.1f to 0 slow down performance by 10x?
by stephencanon on Sunday March 11, 2012 @03:22PM
(#3691017)
Adding zero (of either sign) has no effect on denormals in an IEEE-754 system. -0.0 and signaling NaNs are the only values which are effected.
Re:Why does changing 0.1f to 0 slow down performance by 10x?
by tlb on Sunday March 11, 2012 @03:38PM
(#3691056)
It can if you set the DAZ (denormals are zero) flag on the Pentium. I don't know if the C & IEEE-754 standards require the optimizer to preserve semantics in that case, but I can see why compiler writers would stay clear of such an optimization.
Re:Why does changing 0.1f to 0 slow down performance by 10x?
by stephencanon on Sunday March 11, 2012 @05:31PM
(#3691341)
Neither the C standard nor IEEE-754 specify anything about floating-point operations in non-standard modes like DAZ or FZ. (Nor do they require that support for signaling NaNs be implemented). The behavior of -0.0 suffices to block the optimization under strict fp modes, however.