diff options
author | Michael Meissner <meissner@linux.ibm.com> | 2018-04-20 21:27:08 +0000 |
---|---|---|
committer | Michael Meissner <meissner@gcc.gnu.org> | 2018-04-20 21:27:08 +0000 |
commit | 661eb8f9e5270df79c21601273219e2a8e282204 (patch) | |
tree | 0177db3daa9c272dc9903521a296e8daf574d0ed /libgcc | |
parent | 8833e667be9d960a556b53bfd25101165b92a0b5 (diff) | |
download | gcc-661eb8f9e5270df79c21601273219e2a8e282204.zip gcc-661eb8f9e5270df79c21601273219e2a8e282204.tar.gz gcc-661eb8f9e5270df79c21601273219e2a8e282204.tar.bz2 |
re PR target/85456 (PowerPC: Using -mabi=ieeelongdouble calls wrong function for __builtin_powi.)
[libgcc]
2018-04-20 Michael Meissner <meissner@linux.ibm.com>
PR target/85456
* config/rs6000/_powikf2.c: New file. Add support for the
__builtin_powil function when long double is IEEE 128-bit floating
point.
* config/rs6000/float128-ifunc.c (__powikf2_resolve): Add
__powikf2 support.
(__powikf2): Likewise.
* config/rs6000/quad-float128.h (__powikf2_sw): Likewise.
(__powikf2_hw): Likewise.
(__powikf2): Likewise.
* config/rs6000/t-float128 (fp128_ppc_funcs): Likewise.
* config/rs6000/t-float128-hw (fp128_hw_func): Likewise.
(_powikf2-hw.c): Likewise.
[gcc]
2018-04-20 Michael Meissner <meissner@linux.ibm.com>
PR target/85456
* config/rs6000/rs6000.c (init_float128_ieee): Add support to call
__powikf2 when long double is IEEE 128-bit.
[gcc/testsuite]
2018-04-20 Michael Meissner <meissner@linux.ibm.com>
PR target/85456
* gcc.target/powerpc/pr85456.c: New test.
From-SVN: r259533
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/ChangeLog | 16 | ||||
-rw-r--r-- | libgcc/config/rs6000/_powikf2.c | 63 | ||||
-rw-r--r-- | libgcc/config/rs6000/float128-ifunc.c | 9 | ||||
-rw-r--r-- | libgcc/config/rs6000/quad-float128.h | 3 | ||||
-rw-r--r-- | libgcc/config/rs6000/t-float128 | 2 | ||||
-rw-r--r-- | libgcc/config/rs6000/t-float128-hw | 8 |
6 files changed, 98 insertions, 3 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 8a645c8..f0361dc 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,19 @@ +2018-04-20 Michael Meissner <meissner@linux.ibm.com> + + PR target/85456 + * config/rs6000/_powikf2.c: New file. Add support for the + __builtin_powil function when long double is IEEE 128-bit floating + point. + * config/rs6000/float128-ifunc.c (__powikf2_resolve): Add + __powikf2 support. + (__powikf2): Likewise. + * config/rs6000/quad-float128.h (__powikf2_sw): Likewise. + (__powikf2_hw): Likewise. + (__powikf2): Likewise. + * config/rs6000/t-float128 (fp128_ppc_funcs): Likewise. + * config/rs6000/t-float128-hw (fp128_hw_func): Likewise. + (_powikf2-hw.c): Likewise. + 2018-04-19 H.J. Lu <hongjiu.lu@intel.com> PR libgcc/85334 diff --git a/libgcc/config/rs6000/_powikf2.c b/libgcc/config/rs6000/_powikf2.c new file mode 100644 index 0000000..7afd096 --- /dev/null +++ b/libgcc/config/rs6000/_powikf2.c @@ -0,0 +1,63 @@ +/* Copyright (C) 1989-2018 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "quad-float128.h" + +/* __powikf3 can be compiled 3 different ways: + + 1) If the assembler does not have support for the IEEE 128-bit insns + (xsaddqp, etc.) it is just compiled as __powikf2. + + 2) If the assembler has IEEE 128-bit floating point support, and __powikf2 + is not previously defined, it is defined as __powikf2_sw. + + 3) If the assembler has IEEE 128-bit floating point support, and __powikf2 + is included by _powikf2-hw.c, which defines __powikf2 as __powikf2_hw. The + __powikf2_hw.c is compiled with -mcpu=power9 and it automatically uses the + IEEE 128-bit instructions. + + For #2/#3, float128-ifunc.c defines an ifunc function for __powikf2, that + will use the software version on power7/power8 systems, and the hardware + version on power9 systems. + + The code is cloned from the code in libgcc2.c (which handles the standard + SF, DF, TF, and XF types). */ + +#if defined(FLOAT128_HW_INSNS) && !defined(__powikf2) +#define __powikf2 __powikf2_sw +#endif + +TFtype +__powikf2 (TFtype x, SItype_ppc m) +{ + unsigned int n = m < 0 ? -m : m; + TFtype y = n % 2 ? x : 1; + while (n >>= 1) + { + x = x * x; + if (n % 2) + y = y * x; + } + return m < 0 ? 1/y : y; +} diff --git a/libgcc/config/rs6000/float128-ifunc.c b/libgcc/config/rs6000/float128-ifunc.c index 13a6045..8fcac24 100644 --- a/libgcc/config/rs6000/float128-ifunc.c +++ b/libgcc/config/rs6000/float128-ifunc.c @@ -84,6 +84,12 @@ __negkf2_resolve (void) return SW_OR_HW (__negkf2_sw, __negkf2_hw); } +static __typeof__ (__powikf2_sw) * +__powikf2_resolve (void) +{ + return SW_OR_HW (__powikf2_sw, __powikf2_hw); +} + static __typeof__ (__floatsikf_sw) * __floatsikf_resolve (void) { @@ -243,6 +249,9 @@ TFtype __divkf3 (TFtype, TFtype) TFtype __negkf2 (TFtype) __attribute__ ((__ifunc__ ("__negkf2_resolve"))); +TFtype __powikf2 (TFtype, SItype_ppc) + __attribute__ ((__ifunc__ ("__powikf2_resolve"))); + CMPtype __eqkf2 (TFtype, TFtype) __attribute__ ((__ifunc__ ("__eqkf2_resolve"))); diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h index e10b25f..1d4d513 100644 --- a/libgcc/config/rs6000/quad-float128.h +++ b/libgcc/config/rs6000/quad-float128.h @@ -72,6 +72,7 @@ extern TFtype __subkf3_sw (TFtype, TFtype); extern TFtype __mulkf3_sw (TFtype, TFtype); extern TFtype __divkf3_sw (TFtype, TFtype); extern TFtype __negkf2_sw (TFtype); +extern TFtype __powikf2_sw (TFtype, SItype_ppc); extern CMPtype __eqkf2_sw (TFtype, TFtype); extern CMPtype __gekf2_sw (TFtype, TFtype); extern CMPtype __lekf2_sw (TFtype, TFtype); @@ -114,6 +115,7 @@ extern TFtype __subkf3_hw (TFtype, TFtype); extern TFtype __mulkf3_hw (TFtype, TFtype); extern TFtype __divkf3_hw (TFtype, TFtype); extern TFtype __negkf2_hw (TFtype); +extern TFtype __powikf2_hw (TFtype, SItype_ppc); extern CMPtype __eqkf2_hw (TFtype, TFtype); extern CMPtype __gekf2_hw (TFtype, TFtype); extern CMPtype __lekf2_hw (TFtype, TFtype); @@ -142,6 +144,7 @@ extern TFtype __subkf3 (TFtype, TFtype); extern TFtype __mulkf3 (TFtype, TFtype); extern TFtype __divkf3 (TFtype, TFtype); extern TFtype __negkf2 (TFtype); +extern TFtype __powikf2 (TFtype, SItype_ppc); extern CMPtype __eqkf2 (TFtype, TFtype); extern CMPtype __nekf2 (TFtype, TFtype); extern CMPtype __gekf2 (TFtype, TFtype); diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128 index 41ad527..8d52521 100644 --- a/libgcc/config/rs6000/t-float128 +++ b/libgcc/config/rs6000/t-float128 @@ -25,7 +25,7 @@ fp128_softfp_obj = $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj) # New functions for software emulation fp128_ppc_funcs = floattikf floatuntikf fixkfti fixunskfti \ extendkftf2-sw trunctfkf2-sw \ - sfp-exceptions _mulkc3 _divkc3 + sfp-exceptions _mulkc3 _divkc3 _powikf2 fp128_ppc_src = $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \ .c,$(fp128_ppc_funcs))) diff --git a/libgcc/config/rs6000/t-float128-hw b/libgcc/config/rs6000/t-float128-hw index 7ab1069..acdddb0 100644 --- a/libgcc/config/rs6000/t-float128-hw +++ b/libgcc/config/rs6000/t-float128-hw @@ -6,9 +6,9 @@ FLOAT128_HW_INSNS = -DFLOAT128_HW_INSNS # New functions for hardware support fp128_hardfp_src = _mulkc3-hw.c _divkc3-hw.c -fp128_hw_funcs = float128-hw _mulkc3-hw _divkc3-hw +fp128_hw_funcs = float128-hw _mulkc3-hw _divkc3-hw _powikf2-hw fp128_hw_src = $(srcdir)/config/rs6000/float128-hw.c _mulkc3-hw.c \ - _divkc3-hw.c + _divkc3-hw.c _powikf2-hw.c fp128_hw_static_obj = $(addsuffix $(objext),$(fp128_hw_funcs)) fp128_hw_shared_obj = $(addsuffix _s$(objext),$(fp128_hw_funcs)) fp128_hw_obj = $(fp128_hw_static_obj) $(fp128_hw_shared_obj) @@ -43,3 +43,7 @@ _mulkc3-hw.c: $(srcdir)/config/rs6000/_mulkc3.c _divkc3-hw.c: $(srcdir)/config/rs6000/_divkc3.c (echo "#define __divkc3 __divkc3_hw"; \ cat $(srcdir)/config/rs6000/_divkc3.c) > _divkc3-hw.c + +_powikf2-hw.c: $(srcdir)/config/rs6000/_powikf2.c + (echo "#define __powikf2 __powikf2_hw"; \ + cat $(srcdir)/config/rs6000/_powikf2.c) > _powikf2-hw.c |