This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran,patch] Call mpfr_check_range after setting emin/emax


FX wrote:
The two patchlets below regtest fine on my system (x86_64-linux, both -m32 and -m64) and fix the issue I am seeing with gfortran.dg/nearest_4.f90. Is it OK to commit?
The arith.c part is OK. However, I wonder whether
@@ -2821,6 +2821,7 @@ gfc_simplify_nearest (gfc_expr *x, gfc_e
   mpfr_set_emin ((mp_exp_t) gfc_real_kinds[kind].min_exponent -
                mpfr_get_prec(result->value.real) + 1);
   mpfr_set_emax ((mp_exp_t) gfc_real_kinds[kind].max_exponent - 1);
+  mpfr_check_range (result->value.real, 0, GMP_RNDU);
shouldn't be rather

mpfr_set_emax ((mp_exp_t) gfc_real_kinds[kind].max_exponent - 1);

 if (mpfr_sgn (s->value.real) > 0)
   {
+  mpfr_check_range (result->value.real, 0, GMP_RNDU);
     mpfr_nextabove (result->value.real);
     mpfr_subnormalize (result->value.real, 0, GMP_RNDU);
   }
 else
   {
+  mpfr_check_range (result->value.real, 0, GMP_RNDD);
     mpfr_nextbelow (result->value.real);
     mpfr_subnormalize (result->value.real, 0, GMP_RNDD);
   }

But I have to admit that I have not thought much about this.

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]