Thread Links | Date Links | ||||
---|---|---|---|---|---|
Thread Prev | Thread Next | Thread Index | Date Prev | Date Next | Date Index |
Arnold Neumaier wrote:
Paul Zimmermann wrote:The problem in your example is not the inlining of the function nan2zero(). The problem is the function call isnan(). If you replace this function by a "x != x" then you will get a better performance which is close to the runtime without a call of nan2zero().right, but Arnold's explicitly mentioned a call to isnan(x).Only for lack of knowledge that x!=x executes much faster. Can someone explain _why_ this is so?
On most floating-point processors there is a hardware instruction to perform the comparision x != x, so this eliminates the overhead of a function call to a potentially more expensive software routine like isnan().
Are the predicates isfinite(x) and/or isinf(x) also much slower than an arithmetic operation? Can they also be replaced by something costing next to nothing?
If one manually writes the comparision relations in assembly code there are usually the desired hardware instructions (e.g., on Intel this would be FXAM). However, I'm not aware of a method to do this using portable C++ code except for the software routines mentioned above.
Nate Hayes