summaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-26 15:04:44 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-26 15:04:44 +0000
commit3fa759a93c9f09fa48c7a4f12d35d0e9d552e82e (patch)
tree974dfbada45151a1464bb76ba72bf9e40597ea73 /gcc/real.c
parent3a8a26d5ca7d9b212be22afe419961368bb8d5e2 (diff)
downloadgcc-3fa759a93c9f09fa48c7a4f12d35d0e9d552e82e.tar.gz
* builtins.c (expand_builtin_pow, fold_builtin_cabs,
fold_builtin_sqrt, fold_builtin_cbrt, fold_builtin_logarithm, fold_builtin_hypot, fold_builtin_pow): Remove uses of dconst3, dconstsqrt2, dconstthird, dconste and/or dconst10. * config/i386/i386.c (ix86_emit_swsqrtsf): Likewise. * emit-rtl.c (dconst3, dconst10, dconstm2, dconstthird, dconstsqrt2, dconste): Delete. (init_emit_once): Likewise. Simplify initializing dconstm1. Constify variable. * real.c (get_real_const): New. * real.h (dconst3, dconst10, dconstm2, dconstthird, dconstsqrt2, dconste): Delete. (real_value_const, get_real_const): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133607 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c
index 38f18a8462a..ac3b7dc02ec 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -2163,6 +2163,49 @@ times_pten (REAL_VALUE_TYPE *r, int exp)
do_divide (r, r, &pten);
}
+/* Returns the special REAL_VALUE_TYPE enumerated by E. */
+
+const REAL_VALUE_TYPE *
+get_real_const (enum real_value_const e)
+{
+ static REAL_VALUE_TYPE value[rv_max];
+
+ gcc_assert (e < rv_max);
+
+ /* Initialize mathematical constants for constant folding builtins.
+ These constants need to be given to at least 160 bits precision. */
+ if (value[e].cl == rvc_zero)
+ switch (e)
+ {
+ case rv_e:
+ {
+ mpfr_t m;
+ mpfr_init2 (m, SIGNIFICAND_BITS);
+ mpfr_set_ui (m, 1, GMP_RNDN);
+ mpfr_exp (m, m, GMP_RNDN);
+ real_from_mpfr (&value[e], m, NULL_TREE, GMP_RNDN);
+ mpfr_clear (m);
+ }
+ break;
+ case rv_third:
+ real_arithmetic (&value[e], RDIV_EXPR, &dconst1, real_digit (3));
+ break;
+ case rv_sqrt2:
+ {
+ mpfr_t m;
+ mpfr_init2 (m, SIGNIFICAND_BITS);
+ mpfr_sqrt_ui (m, 2, GMP_RNDN);
+ real_from_mpfr (&value[e], m, NULL_TREE, GMP_RNDN);
+ mpfr_clear (m);
+ }
+ break;
+ default:
+ gcc_unreachable();
+ }
+
+ return &value[e];
+}
+
/* Fills R with +Inf. */
void