aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/arith.c19
-rw-r--r--gcc/fortran/gfortran.h3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/integer_exponentiation_4.f907
5 files changed, 39 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2cfbe24..61196df 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gfortran.h: Define HAVE_mpc_pow.
+ * arith.c (complex_reciprocal, complex_pow): If HAVE_mpc_pow,
+ don't define these functions.
+ (arith_power): If HAVE_mpc_pow, use mpc_pow.
+
2009-06-26 Janus Weil <janus@gcc.gnu.org>
PR fortran/39997
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index 2aa3c40..dddf7e0 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -896,6 +896,7 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
/* Compute the reciprocal of a complex number (guaranteed nonzero). */
+#if ! defined(HAVE_mpc_pow)
static void
complex_reciprocal (gfc_expr *op)
{
@@ -922,6 +923,7 @@ complex_reciprocal (gfc_expr *op)
}
#endif
}
+#endif /* ! HAVE_mpc_pow */
/* Raise a complex number to positive power (power > 0).
@@ -932,6 +934,7 @@ complex_reciprocal (gfc_expr *op)
"Seminumerical Algorithms", Vol. 2, "The Art of Computer Programming",
3rd Edition, 1998. */
+#if ! defined(HAVE_mpc_pow)
static void
complex_pow (gfc_expr *result, gfc_expr *base, mpz_t power)
{
@@ -988,6 +991,7 @@ complex_pow (gfc_expr *result, gfc_expr *base, mpz_t power)
mpfr_clears (x_r, x_i, tmp, re, im, NULL);
}
+#endif /* ! HAVE_mpc_pow */
/* Raise a number to a power. */
@@ -1107,6 +1111,15 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
case BT_COMPLEX:
{
+#ifdef HAVE_mpc_pow
+ mpc_t apower;
+ gfc_set_model (mpc_realref (op1->value.complex));
+ mpc_init2 (apower, mpfr_get_default_prec());
+ mpc_set_z (apower, op2->value.integer, GFC_MPC_RND_MODE);
+ mpc_pow(result->value.complex, op1->value.complex, apower,
+ GFC_MPC_RND_MODE);
+ mpc_clear (apower);
+#else
mpz_t apower;
/* Compute op1**abs(op2) */
@@ -1118,6 +1131,7 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
/* If (op2 < 0), compute the inverse. */
if (power_sign < 0)
complex_reciprocal (result);
+#endif /* HAVE_mpc_pow */
}
break;
@@ -1159,6 +1173,10 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
return ARITH_PROHIBIT;
}
+#ifdef HAVE_mpc_pow
+ mpc_pow (result->value.complex, op1->value.complex,
+ op2->value.complex, GFC_MPC_RND_MODE);
+#else
{
mpfr_t x, y, r, t;
@@ -1211,6 +1229,7 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
mpfr_mul (mpc_imagref (result->value.complex), x, y, GFC_RND_MODE);
mpfr_clears (r, t, x, y, NULL);
}
+#endif /* HAVE_mpc_pow */
}
break;
default:
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index de0025b..8099168 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1558,6 +1558,9 @@ gfc_intrinsic_sym;
#include <mpfr.h>
#ifdef HAVE_mpc
#include <mpc.h>
+# if MPC_VERSION >= MPC_VERSION_NUM(0,6,1)
+# define HAVE_mpc_pow
+# endif
#else
#define mpc_realref(X) ((X).r)
#define mpc_imagref(X) ((X).i)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dc56bd0..aa693ce 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gfortran.dg/integer_exponentiation_4.f90: Temporarily
+ comment out some values and add some cases.
+
2009-06-27 Paolo Bonzini <bonzini@gnu.org>
PR testsuite/40567
diff --git a/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90 b/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90
index 55d1dcd..e934d28 100644
--- a/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90
+++ b/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90
@@ -38,7 +38,10 @@ program test
print *, nearest(1.0,-1.0)**(-huge(0)) ! { dg-error "Arithmetic overflow" }
!!!!!! COMPLEX BASE !!!!!!
- print *, (2.0,-4.3)**huge(0) ! { dg-error "Arithmetic NaN" }
- print *, (2.0,-4.3)**(-huge(0)) ! { dg-error "Arithmetic NaN" }
+! Put these lines back in (and "no-" -> "dg-") prior to gcc-4.5.
+! print *, (2.0,-4.3)**huge(0) ! { no-error "Arithmetic overflow" }
+! print *, (2.0,-4.3)**huge(0_8) ! { no-error "Arithmetic overflow" }
+! print *, (2.0,-4.3)**(-huge(0))
+! print *, (2.0,-4.3)**(-huge(0_8))
end program test