Re: Are f.p. manipulation functions only used in initialization?



In article <QdCdnaPuP40qNo7VnZ2dnUVZ_hWdnZ2d@xxxxxxxxxxx>,
"James Van Buskirk" <not_valid@xxxxxxxxxxx> writes:
"Steven G. Kargl" <kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:fv086u$roe$1@xxxxxxxxxxxxxxxxxxxxxxxxxx

Appears to work for me. Perhaps, it's an OS problem.

Thank you for testing. Maybe an OS problem or a regression. What
version are you using? I'm on 20080421.

On i386-*-freebsd, I have
mobile:kargl[203] gfc --version
GNU Fortran (GCC) 4.2.3 20080130 (prerelease)

On amd64-*-freebsd, I have

troutmask:kargl[201] gfc --version
GNU Fortran (GCC) 4.2.3 20071024 (prerelease)

and

troutmask:kargl[202] ../sgk/work/4x/bin/gfortran --version
GNU Fortran (GCC) 4.4.0 20080415 (experimental)


All versions give the same results.



I ran into another problem that may be with the documentation. In:

http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

It says:

"-mpc32
-mpc64
-mpc80

First time I've seen these flags. These appear to be new in 4.4
(at least 4.2.x does not recognize the options).

Set 80387 floating-point precision to 32, 64 or 80 bits. When
-mpc32 is specified, the significands of results of floating-point
operations are rounded to 24 bits (single precision); -mpc64 rounds
the the significands of results of floating-point operations to 53
bits (double precision) and -mpc80 rounds the significands of results
of floating-point operations to 64 bits (extended double precision),
which is the default. When this option is used, floating-point
operations in higher precisions are not available to the programmer
without setting the FPU control word explicitly.

Setting the rounding of floating-point operations to less than the
default 80 bits can speed some programs by 2% or more. Note that some
mathematical libraries assume that extended precision (80 bit)
floating-point operations are enabled by default; routines in such
libraries could suffer significant loss of accuracy, typically through
so-called "catastrophic cancellation", when this option is used to set
the precision to less than extended precision."

I doubt gfortran honors these flags, particular with anything that
gfortran can constant fold or the results of a numeric inquiry function.

(program snipped)

So you can see that gfortran isn't setting precision control to b'11'
even with the -mpc80 switch in effect so that real(10) arithmetic
isn't working until I set the x87 control word by hand. Probably I'm
just missing something in the documentation somewhere but it can sure
be hard to find it from a standing start.

The ChangeLog entry for these option suggest that they may be linux
(Unix-like OS?) specific.

2007-04-03 Uros Bizjak <ubizjak@xxxxxxxxx>

* config.gcc (i[34567]86-*-linux*): Add i386/t-crtpc to tm-file.
(x86_64-*-linux*): Ditto.
* config/i386/i386.opt (mpc): New option.
* config/i386/i386.c (overrride_options): Handle
ix87_precision_string.
* config/i386/crtprec.c: New file.
* config/i386/t-crtpc: Ditto.
* config/i386/linux.h (ENDFILE_SPEC): Add handling of -mpc32, -mpc64
and -mpc80 options.
* config/i386/linux64.h (ENDFILE_SPEC): Ditto.
* config/i386/t-linux64 (EXTRA_MULTILIB_PARTS): Add
crtprec32.o, crtprec64.o and crtprec80.o.

* doc/invoke.texi (Machine Dependent Options): Add -mpc32, -mpc64
and -mpc80 options.
(i386 and x86-64 Options): Document -mpc32, -mpc64 and -mpc80 options.


--
Steve
http://troutmask.apl.washington.edu/~kargl/
.