From 7908275680344f3baec461cfc5be046b1f72ec68 Mon Sep 17 00:00:00 2001 From: ghazi Date: Thu, 11 Sep 2003 21:40:41 +0000 Subject: [PATCH] * builtins.c (builtin_dconsts_init, dconstpi, dconste, init_builtin_dconsts): Delete. * emit-rtl.c (dconstpi, dconste): Define. (init_emit_once): Initialize dconstpi & dconste. * real.h (dconstpi, dconste): Declare. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71320 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/builtins.c | 28 ---------------------------- gcc/emit-rtl.c | 9 +++++++++ gcc/real.h | 2 ++ 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0dfd488db67..d6d762417e8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2003-09-11 Kaveh R. Ghazi + + * builtins.c (builtin_dconsts_init, dconstpi, dconste, + init_builtin_dconsts): Delete. + * emit-rtl.c (dconstpi, dconste): Define. + (init_emit_once): Initialize dconstpi & dconste. + * real.h (dconstpi, dconste): Declare. + 2003-09-11 Alexandre Oliva PR fortran/11522 diff --git a/gcc/builtins.c b/gcc/builtins.c index dfa047f06f5..4df0e95b7f6 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -79,11 +79,6 @@ tree built_in_decls[(int) END_BUILTINS]; required to implement the function call in all cases. */ tree implicit_built_in_decls[(int) END_BUILTINS]; -/* Trigonometric and mathematical constants used in builtin folding. */ -static bool builtin_dconsts_init = 0; -static REAL_VALUE_TYPE dconstpi; -static REAL_VALUE_TYPE dconste; - static int get_pointer_alignment (tree, unsigned int); static tree c_strlen (tree, int); static const char *c_getstr (tree); @@ -157,27 +152,12 @@ static tree fold_trunc_transparent_mathfn (tree); static bool readonly_data_expr (tree); static rtx expand_builtin_fabs (tree, rtx, rtx); static rtx expand_builtin_cabs (tree, rtx); -static void init_builtin_dconsts (void); static tree fold_builtin_cabs (tree, tree, tree); static tree fold_builtin_trunc (tree); static tree fold_builtin_floor (tree); static tree fold_builtin_ceil (tree); static tree fold_builtin_bitop (tree); -/* Initialize mathematical constants for constant folding builtins. - These constants need to be given to at least 160 bits precision. */ - -static void -init_builtin_dconsts (void) -{ - real_from_string (&dconstpi, - "3.1415926535897932384626433832795028841971693993751058209749445923078"); - real_from_string (&dconste, - "2.7182818284590452353602874713526624977572470936999595749669676277241"); - - builtin_dconsts_init = true; -} - /* Return the alignment in bits of EXP, a pointer valued expression. But don't return more than MAX_ALIGN no matter what. The alignment returned is, by default, the alignment of the thing that @@ -6009,8 +5989,6 @@ fold_builtin_logarithm (tree exp, const REAL_VALUE_TYPE *value) case BUILT_IN_EXPF: case BUILT_IN_EXPL: /* Prepare to do logN(exp(exponent) -> exponent*logN(e). */ - if (! builtin_dconsts_init) - init_builtin_dconsts (); x = build_real (type, real_value_truncate (TYPE_MODE (type), dconste)); exponent = TREE_VALUE (TREE_OPERAND (arg, 1)); @@ -6283,8 +6261,6 @@ fold_builtin (tree exp) case BUILT_IN_EXP: case BUILT_IN_EXPF: case BUILT_IN_EXPL: - if (! builtin_dconsts_init) - init_builtin_dconsts (); return fold_builtin_exponent (exp, &dconste); case BUILT_IN_EXP2: case BUILT_IN_EXP2F: @@ -6300,8 +6276,6 @@ fold_builtin (tree exp) case BUILT_IN_LOG: case BUILT_IN_LOGF: case BUILT_IN_LOGL: - if (! builtin_dconsts_init) - init_builtin_dconsts (); return fold_builtin_logarithm (exp, &dconste); break; case BUILT_IN_LOG2: @@ -6353,8 +6327,6 @@ fold_builtin (tree exp) { REAL_VALUE_TYPE cst; - if (! builtin_dconsts_init) - init_builtin_dconsts (); real_convert (&cst, TYPE_MODE (type), &dconstpi); cst.exp -= 2; return build_real (type, cst); diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index fbd72244b91..d5ff690cb3f 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -116,6 +116,8 @@ REAL_VALUE_TYPE dconstm1; REAL_VALUE_TYPE dconstm2; REAL_VALUE_TYPE dconsthalf; REAL_VALUE_TYPE dconstthird; +REAL_VALUE_TYPE dconstpi; +REAL_VALUE_TYPE dconste; /* All references to the following fixed hard registers go through these unique rtl objects. On machines where the frame-pointer and @@ -5427,6 +5429,13 @@ init_emit_once (int line_numbers) real_arithmetic (&dconstthird, RDIV_EXPR, &dconst1, &dconst3); + /* Initialize mathematical constants for constant folding builtins. + These constants need to be given to at least 160 bits precision. */ + real_from_string (&dconstpi, + "3.1415926535897932384626433832795028841971693993751058209749445923078"); + real_from_string (&dconste, + "2.7182818284590452353602874713526624977572470936999595749669676277241"); + for (i = 0; i < (int) ARRAY_SIZE (const_tiny_rtx); i++) { REAL_VALUE_TYPE *r = diff --git a/gcc/real.h b/gcc/real.h index 0543b8f8f9d..4799204de56 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -333,6 +333,8 @@ extern REAL_VALUE_TYPE dconstm1; extern REAL_VALUE_TYPE dconstm2; extern REAL_VALUE_TYPE dconsthalf; extern REAL_VALUE_TYPE dconstthird; +extern REAL_VALUE_TYPE dconstpi; +extern REAL_VALUE_TYPE dconste; /* Function to return a real value (not a tree node) from a given integer constant. */ -- 2.11.0