Re: Function ieee_value( r, IEEE_SIGNALING_NAN )
- From: robert.corbett@xxxxxxx
- Date: Tue, 10 Jun 2008 17:03:23 -0700 (PDT)
On Jun 6, 12:32 pm, "John Keenan"
<john.removeme.kee...@xxxxxxxxxxxxxxxxxxx> wrote:
"Steven Correll" wrote
use, intrinsic :: ieee_arithmetic
implicit none
real :: r
r = ieee_value(r, IEEE_SIGNALING_NAN)
Changing the subject a bit...
I do not believe the design of function ieee_value can work as
intended in this case (at least on Intel CPUs).
Any compiler implementor worth his salt could make the
example assignment work. There is no need for the value
to go through the floating-point registers. The IEEE_*
modules are instrinsic modules, and the procedures defined
in them are effectively intrinsic procedures. A compiler
knows what they should do and can generate code that will
do it.
From a quick google search it appears function ieee_value's
second argument specifies a signaling NaN should be returned
of the same type as the first argument (please correct me if
I am wrong).
You are correct that the value produced by the function
reference in the example should be a signaling NaN.
Whether the value has to be returned as if it were a
function reference of a user-defined function is another
matter. In this case, the function value is a constant
bit pattern. The assignment statement can be implemented
as a sequence of MOV instructions.
My experimentation with Intel CPUs has shown it is not
possible to store a signaling NaN in a floating point
register.
It is easy to store a signaling NaN into a floating-point
register. I am assuming you mean a register in the x87
floating-point stack, but it is easy enough to do it for
the XMM registers as well. In the case of the x87 stack,
simply do an FLD instruction to load an 80-bit signaling
NaN. The signaling NaN will be pushed onto the stack
unchanged, and with no exception being signaled.
Doing so always results in a quiet NaN being stored in
the floating point register. The only way I was ever
able to create a signaling NaN was to do so in-situ
using integer manipulation.
Right, and the compiler could do it too.
My point is that the I do not believe the line:
r = ieee_value(r, IEEE_SIGNALING_NAN)
can work unless the compiler can do so without using any
of the CPUs floating point registers.
If the SSE and SSE2 instructions are available, it could
be done by using those registers for single- and double-
precision singling NaNs, but if those instructions are
not available, integer MOVs can do the job.
Having the compiler special case the IEEE_* functions is no
different from having the compiler special case the normal
instrinsic functions.
Bob Corbett
.
- Follow-Ups:
- Re: Function ieee_value( r, IEEE_SIGNALING_NAN )
- From: Greg Lindahl
- Re: Function ieee_value( r, IEEE_SIGNALING_NAN )
- References:
- Re: Garbage in dead zone
- From: Steven Correll
- Function ieee_value( r, IEEE_SIGNALING_NAN )
- From: John Keenan
- Re: Garbage in dead zone
- Prev by Date: Re: The linf project (2)
- Next by Date: Re: The linf project (2)
- Previous by thread: Re: Function ieee_value( r, IEEE_SIGNALING_NAN )
- Next by thread: Re: Function ieee_value( r, IEEE_SIGNALING_NAN )
- Index(es):
Relevant Pages
|
|