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
This commit is contained in:
Michael Meissner 2018-04-20 21:27:08 +00:00 committed by Michael Meissner
parent 8833e667be
commit 661eb8f9e5
10 changed files with 124 additions and 3 deletions

View File

@ -1,3 +1,9 @@
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.
2018-04-20 Kito Cheng <kito.cheng@gmail.com>
* config/riscv/riscv.c (riscv_first_stack_step): Round up min

View File

@ -18657,6 +18657,7 @@ init_float128_ieee (machine_mode mode)
set_optab_libfunc (sdiv_optab, mode, "__divkf3");
set_optab_libfunc (sqrt_optab, mode, "__sqrtkf2");
set_optab_libfunc (abs_optab, mode, "__abstkf2");
set_optab_libfunc (powi_optab, mode, "__powitkf2");
set_optab_libfunc (eq_optab, mode, "__eqkf2");
set_optab_libfunc (ne_optab, mode, "__nekf2");

View File

@ -1,3 +1,8 @@
2018-04-20 Michael Meissner <meissner@linux.ibm.com>
PR target/85456
* gcc.target/powerpc/pr85456.c: New test.
2018-04-20 Bill Schmidt <wschmidt@linux.ibm.com>
* g++.dg/ext/undef-bool-1.C: Require lp64.

View File

@ -0,0 +1,14 @@
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-require-effective-target powerpc_p8vector_ok } */
/* { dg-options "-O2 -mpower8-vector -mabi=ieeelongdouble -Wno-psabi" } */
/* Check that the __builtin_powil generates a call to the correct function
when long double uses IEEE 128-bit floating point. */
long double
do_powl (long double a, int i)
{
return __builtin_powil (a, i);
}
/* { dg-final { scan-assembler "bl __powikf2" } } */

View File

@ -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

View File

@ -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;
}

View File

@ -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")));

View File

@ -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);

View File

@ -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)))

View File

@ -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