From 3a546d4d9bea0eef0b2871663fb00c76ab9bb7da Mon Sep 17 00:00:00 2001
From: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date: Wed, 20 May 2009 00:16:38 +0000
Subject: [PATCH] re PR libfortran/37754 (READ I/O Performance regression from 4.3 to 4.4/4.5)

2009-05-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37754
	* io/write_float.def: Simplify format calculation.

From-SVN: r147725
---
 libgfortran/ChangeLog          |  5 +++++
 libgfortran/io/write_float.def |  9 ++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 3835279..e9acb8b 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+	PR libfortran/37754
+	* io/write_float.def: Simplify format calculation.
+	
 2009-05-07  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
 	PR fortran/22423
diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def
index acf47fb..9804d7b 100644
--- a/libgfortran/io/write_float.def
+++ b/libgfortran/io/write_float.def
@@ -603,7 +603,7 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \
   int d = f->u.real.d;\
   int w = f->u.real.w;\
   fnode *newf;\
-  GFC_REAL_ ## x exp_d;\
+  GFC_REAL_ ## x rexp_d;\
   int low, high, mid;\
   int ubound, lbound;\
   char *p;\
@@ -612,8 +612,8 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \
   save_scale_factor = dtp->u.p.scale_factor;\
   newf = (fnode *) get_mem (sizeof (fnode));\
 \
-  exp_d = calculate_exp_ ## x (d);\
-  if ((m > 0.0 && m < 0.1 - 0.05 / exp_d) || (m >= exp_d - 0.5 ) ||\
+  rexp_d = calculate_exp_ ## x (-d);\
+  if ((m > 0.0 && m < 0.1 - 0.05 * rexp_d) || (rexp_d * (m + 0.5) >= 1.0) ||\
       ((m == 0.0) && !(compile_options.allow_std & GFC_STD_F2003)))\
     { \
       newf->format = FMT_E;\
@@ -635,8 +635,7 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \
       GFC_REAL_ ## x temp;\
       mid = (low + high) / 2;\
 \
-      temp = (calculate_exp_ ## x (mid) - \
-	      5 * calculate_exp_ ## x (mid - d - 1)) / 10;\
+      temp = (calculate_exp_ ## x (mid - 1) * (1 - 0.5 * rexp_d));\
 \
       if (m < temp)\
         { \
--
libgit2 0.26.0