What is the relevance of Stack Overflow question/answer Why does changing 0.1f to 0 slow down performance by 10x? for Objective-C? If there is any relevance, how should this change my coding habits? Is there some way to shut off denormalized floating points on Mac OS X?
It seems like this is completely irrelevant to iOS. Is that correct?
As I said in response to your comment there:
Update
I just tested. On Mac OS X on x86 the slowdown is observed, on iOS on ARMv7 it is not (default build settings).
And as to be expected, running on iOS simulator (on x86) denormalized floats appear again.
Interestingly,
FLT_MINandDBL_MINrespectively are defined to the smallest non-denormalized number (on iOS, Mac OS X, and Linux). Strange things happen usingin your code; the compiler happily sets a denormalized constant, but as soon as the (arm) CPU touches it, it is set to zero:
Outputs:
So a quick runtime check if denormalization is supported can be:
(“given without even the implied warranty of fitness for any purpose”)
This is what ARM has to say on flush to zero mode: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204h/Bcfheche.html
Update<<1
This is how you disable flush to zero mode on ARMv7:
with the following surprising result.
You can clearly see that the denormalization comes at zero cost. (For an iPad 2. On iPhone 4, it comes at a small cost of a 10% slowdown.)