aboutsummaryrefslogtreecommitdiff
path: root/gcc/real.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-10-07 08:09:45 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-10-07 08:09:45 +0000
commitd01db77a06a80459acf79e963c55e3b94106eeb3 (patch)
tree26df13af657839b7995fa4de21f93310ada1c766 /gcc/real.h
parent5b5dce39b8c076c185ce1fa19d4800d6129f3f53 (diff)
downloadgcc-d01db77a06a80459acf79e963c55e3b94106eeb3.zip
gcc-d01db77a06a80459acf79e963c55e3b94106eeb3.tar.gz
gcc-d01db77a06a80459acf79e963c55e3b94106eeb3.tar.bz2
Cache reals for 1/4, 1/6 and 1/9
We have a global 1/2 and a cached 1/3, but recalculate 1/4, 1/6 and 1/9 each time we need them. That seems a bit arbitrary and makes the folding code more noisy (especially once it's moved to match.pd). This patch caches the other three constants too. Bootstrapped & regression-tested on x86_64-linux-gnu. gcc/ * real.h (dconst_quarter, dconst_sixth, dconst_ninth): New macros. (dconst_quarter_ptr, dconst_sixth_ptr, dconst_ninth_ptr): Declare. * real.c (CACHED_FRACTION): New helper macro. (dconst_third_ptr): Use it. (dconst_quarter_ptr, dconst_sixth_ptr, dconst_ninth_ptr): New. * builtins.c (fold_builtin_sqrt): Use dconst_quarter and dconst_sixth. (fold_builtin_cbrt): Use dconst_sixth and dconst_ninth. From-SVN: r228561
Diffstat (limited to 'gcc/real.h')
-rw-r--r--gcc/real.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/real.h b/gcc/real.h
index 1497279..706859b 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -409,15 +409,21 @@ extern REAL_VALUE_TYPE dconst2;
extern REAL_VALUE_TYPE dconstm1;
extern REAL_VALUE_TYPE dconsthalf;
-#define dconst_e() (*dconst_e_ptr ())
-#define dconst_third() (*dconst_third_ptr ())
-#define dconst_sqrt2() (*dconst_sqrt2_ptr ())
+#define dconst_e() (*dconst_e_ptr ())
+#define dconst_third() (*dconst_third_ptr ())
+#define dconst_quarter() (*dconst_quarter_ptr ())
+#define dconst_sixth() (*dconst_sixth_ptr ())
+#define dconst_ninth() (*dconst_ninth_ptr ())
+#define dconst_sqrt2() (*dconst_sqrt2_ptr ())
/* Function to return the real value special constant 'e'. */
extern const REAL_VALUE_TYPE * dconst_e_ptr (void);
-/* Returns the special REAL_VALUE_TYPE corresponding to 1/3. */
-extern const REAL_VALUE_TYPE * dconst_third_ptr (void);
+/* Returns a cached REAL_VALUE_TYPE corresponding to 1/n, for various n. */
+extern const REAL_VALUE_TYPE *dconst_third_ptr (void);
+extern const REAL_VALUE_TYPE *dconst_quarter_ptr (void);
+extern const REAL_VALUE_TYPE *dconst_sixth_ptr (void);
+extern const REAL_VALUE_TYPE *dconst_ninth_ptr (void);
/* Returns the special REAL_VALUE_TYPE corresponding to sqrt(2). */
extern const REAL_VALUE_TYPE * dconst_sqrt2_ptr (void);