diff options
author | Richard Guenther <rguenth@gcc.gnu.org> | 2005-02-09 20:58:13 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2005-02-09 20:58:13 +0000 |
commit | 17684d462957afd5011d71db40e9a96c63225d2c (patch) | |
tree | 347cc9d98b8029f4811e05bd8d3f3df4c5a4ced7 /gcc/libgcc2.c | |
parent | 8ca3515fbe765aef349c8d6f848539bf11d3d6df (diff) | |
download | gcc-17684d462957afd5011d71db40e9a96c63225d2c.zip gcc-17684d462957afd5011d71db40e9a96c63225d2c.tar.gz gcc-17684d462957afd5011d71db40e9a96c63225d2c.tar.bz2 |
re PR middle-end/19402 (__builtin_powi? still missing)
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.
From-SVN: r94774
Diffstat (limited to 'gcc/libgcc2.c')
-rw-r--r-- | gcc/libgcc2.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 1b1455d..2d47c0d 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 |