This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/24518] Intrinsic MOD incorrect for large arg1/arg2 and slow.
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2006 12:22:57 -0000
- Subject: [Bug fortran/24518] Intrinsic MOD incorrect for large arg1/arg2 and slow.
- References: <bug-24518-9236@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2006-06-20 12:22 -------
Why exactly aren't we using BUILT_IN_FMOD{F,,L}?
$ cat a.f90
real*8 :: x = 10.0e9
do i = 10, 22
x = 10d0 * x
print '(a,i2,a,g14.8," = ",g14.8)', "mod (10**",i,", 1.7_8) = ", &
fmod (x, 1.7_8), mod (x, 1.7_8);
end do
end
$ cat a.c
#include <math.h>
double fmod_ (double *x, double *y)
{ return fmod(*x,*y); }
$ gfortran a.f90 a.c && ./a.out
mod (10**10, 1.7_8) = 1.3000026 = 1.3000026
mod (10**11, 1.7_8) = 1.1000261 = 1.1000261
mod (10**12, 1.7_8) = 0.80026120 = 0.80026150
mod (10**13, 1.7_8) = 1.2026123 = 1.2026138
mod (10**14, 1.7_8) = 0.12612289 = 0.12609863
mod (10**15, 1.7_8) = 1.2612289 = 1.2607422
mod (10**16, 1.7_8) = 0.71228945 = 5.8125000
mod (10**17, 1.7_8) = 0.32289469 = -50.687500
mod (10**18, 1.7_8) = 1.5289470 = 364.00000
mod (10**19, 1.7_8) = 1.6894697 = -.70000000E+20
mod (10**20, 1.7_8) = 1.5946971 = -.70000000E+21
mod (10**21, 1.7_8) = 0.64697063 = -.70000000E+22
mod (10**22, 1.7_8) = 0.86970627 = -.70000000E+23
It's actually slower: 55% slower at -O0 and 230% slower at -O2, on a loop with
real(kind=8) variables modulo. But then, we're already testing whether the
division can be represented by an integer, we could call fmod only in the case
where it's not possible. Opinions?
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
Last reconfirmed|2006-01-24 04:26:11 |2006-06-20 12:22:57
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24518