summaryrefslogtreecommitdiff
path: root/gcc/libgcc2.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-09 20:58:13 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-09 20:58:13 +0000
commit757c219d39633206faa75b5b10219b6326a5f4d4 (patch)
tree347cc9d98b8029f4811e05bd8d3f3df4c5a4ced7 /gcc/libgcc2.c
parent8f385311c8ec00ba494c7a31960f296d421cfded (diff)
downloadgcc-757c219d39633206faa75b5b10219b6326a5f4d4.tar.gz
2005-02-09 Richard Guenther <rguenth@gcc.gnu.org>
PR middle-end/19402 * builtins.def: New __builtin_powi[lf]. * builtins.c (mathfn_built_in): Handle BUILT_IN_POWI. (expand_builtin_powi): New function. (expand_builtin): Dispatch to expand_builtin_powi. * libgcc2.h: Add prototypes for __builtin_powi[lf]. * libgcc2.c: Add __builtin_powi[lf] implementation. * mklibgcc.in: Add __builtin_powi[lf] to lib2funcs. * optabs.h: Add powi_optab. * optabs.c (init_optabs): Initialize powi_optab. * doc/extend.texi: Document __builtin_powi[lf]. * gcc.dg/pr19402-1.c: New testcase. * gcc.dg/pr19402-2.c: likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94774 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/libgcc2.c')
-rw-r--r--gcc/libgcc2.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c
index 1b1455d5d8d..2d47c0d7f64 100644
--- a/gcc/libgcc2.c
+++ b/gcc/libgcc2.c
@@ -1465,6 +1465,42 @@ __fixunssfSI (SFtype a)
}
#endif
+/* Integer power helper used from __builtin_powi for non-constant
+ exponents. */
+
+#if defined(L_powisf2) || defined(L_powidf2) \
+ || (defined(L_powixf2) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80) \
+ || (defined(L_powitf2) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
+# if defined(L_powisf2)
+# define TYPE SFtype
+# define NAME __powisf2
+# elif defined(L_powidf2)
+# define TYPE DFtype
+# define NAME __powidf2
+# elif defined(L_powixf2)
+# define TYPE XFtype
+# define NAME __powixf2
+# elif defined(L_powitf2)
+# define TYPE TFtype
+# define NAME __powitf2
+# endif
+
+TYPE
+NAME (TYPE x, Wtype m)
+{
+ UWtype n = m < 0 ? -m : m;
+ TYPE y = n % 2 ? x : 1;
+ while (n >>= 1)
+ {
+ x = x * x;
+ if (n % 2)
+ y = y * x;
+ }
+ return m < 0 ? 1/y : y;
+}
+
+#endif
+
/* From here on down, the routines use normal data types. */
#define SItype bogus_type