Re: Function ieee_value( r, IEEE_SIGNALING_NAN )



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
.



Relevant Pages

  • Re: Ive seen the future...and it works! (was: my view on this assembler is blah)
    ... The compiler has the advantage, granted, that it can "remember" what all ... the registers are...but "remembering" isn't the challenge here, ... registers with the CPU... ... The HLLs, though - shackled by a whole bunch of factors that they have to ...
    (alt.lang.asm)
  • Ive seen the future...and it works! (was: my view on this assembler is blah)
    ... > though the registers are few. ... And the 64 bit CPU designers ... what my Borland _C++ compiler_ does when you ask for assembly output...it ... out programming with something like BASIC or Pascal, ...
    (alt.lang.asm)
  • Re: 32-bit vs. 64-bit x86 Speed
    ... You compiler people probably have intimate knowledge of the ISA ... What is the underlying chip architecture and memory subsystem? ... Do you use the x87 floating point stack or xmm registers? ... Do you use of tuned math and string libraries? ...
    (comp.compilers)
  • Attitudes (was: Some stack questions)
    ... On a register-starved architecture like the Intel x86, ... > compiler allocates registers efficiently so that most operations ... > Parentheses are part of the syntax, and allow the compiler to more ...
    (comp.lang.c.moderated)
  • Re: Moving to 64 bit
    ... 30% faster than in 32 bit mode because it offers twice as many registers. ... I think you have the choice with the gnu-cc compiler. ... It depends on your programming style, and whether the optimizer in the ... Back when a friend and I were writing the optimizer for the C compiler, ...
    (comp.os.linux.misc)