[Patch, Fortran] Rework of floating point number reading

Daniel Kraft d@domob.eu
Mon Dec 29 19:43:00 GMT 2008


Hi,

here's a full patch for my proposed changes to libgfortran's floating 
point reading.  With the attached test case, I see a speed-up from 31s 
to 18s (the 31 being with unpatched gfortran 4.3, but also 4.4 had a 
similar speed before I did the patch).  In libgfortran/io/read.c:read_f, 
currently the number is "parsed" but only to put it back as string, 
handling special things like BLANK_NULL/BLANK_ZERO; this string is then 
again parsed using strtod & friends.  With the patch, strtod is never 
called but instead the number directly calculated during this first pass.

I see no regressions on GNU/Linux-x86-32.  Is this patch ok in general? 
  I do however not want to commit it as-is; my goal is to get rid of 
io/read.c:convert_real, but I saw it is used two times in list_read.c, 
also.  There seems to be a similar practice of saving to a string and 
re-parsing with convert_real; if my patch is ok, I would like to work 
out a common system for handling all of those cases in one and do only 
one pass there, too.

As I'm no expert on libgfortran and IO, I would very welcome any 
comments!  Also, as I fear my patch could introduce some rounding-errors 
to parsing, I would like to get test results from some other platforms 
as well.

And finally, profiling showed that the test-program attached spends most 
time in real_f after the patch, but still around 6% in pow; I guess this 
is because of the "powl (10.0, exponent)" at the end; by using a 
lookup-table, we could get rid of this call.  Do you think this is worth it?

Thanks,
Daniel

-- 
Done:  Arc-Bar-Cav-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri-Ran
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081229/4cdba055/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081229/4cdba055/attachment.f90>


More information about the Gcc-patches mailing list