]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
simplify.c (gfc_simplify_exponent): Fix exponent(tiny(x))
authorSteven G. Kargl <kargls@comcast.net>
Thu, 7 Apr 2005 18:26:37 +0000 (18:26 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 7 Apr 2005 18:26:37 +0000 (18:26 +0000)
From-SVN: r97792

gcc/fortran/ChangeLog
gcc/fortran/simplify.c

index d7cbdc0f16e08f7c8e34b0dc1eca8484558bbd85..e114853a20ab55cd05432fe525b0c8e87fbddab3 100644 (file)
@@ -1,3 +1,7 @@
+2005-04-07  Steven G. Kargl  <kargls@comcast.net>
+
+       * simplify.c (gfc_simplify_exponent): Fix exponent(tiny(x))
+
 2005-04-06  Steven G. Kargl  <kargls@comcast.net>
 
        * invoke.texi: Remove documentation of -std=f90 
index c2117148839b932cc615dff9c981f64c61d3970f..add391f195e9c3b18e16769ee40542e9ec4ec494 100644 (file)
@@ -967,6 +967,7 @@ gfc_simplify_exp (gfc_expr * x)
 gfc_expr *
 gfc_simplify_exponent (gfc_expr * x)
 {
+  int i;
   mpfr_t tmp;
   gfc_expr *result;
 
@@ -991,6 +992,12 @@ gfc_simplify_exponent (gfc_expr * x)
 
   gfc_mpfr_to_mpz (result->value.integer, tmp);
 
+  /* The model number for tiny(x) is b**(emin - 1) where b is the base and emin
+     is the smallest exponent value.  So, we need to add 1 if x is tiny(x).  */
+  i = gfc_validate_kind (x->ts.type, x->ts.kind, false);
+  if (mpfr_cmp (x->value.real, gfc_real_kinds[i].tiny) == 0)
+    mpz_add_ui (result->value.integer,result->value.integer, 1);
+
   mpfr_clear (tmp);
 
   return range_check (result, "EXPONENT");