On Fri, Apr 20, 2018 at 10:52:57AM -0500, Segher Boessenkool wrote:
> Hi Mike,
> 
> On Thu, Apr 19, 2018 at 12:33:45AM -0400, Michael Meissner wrote:
> > This patch adds __powikf2 to libgcc, and makes GCC use it for 
> > __builtin_powil
> > when long double is IEEE 128-bit (-mabi=ieeelongdouble).
> > 
> > I tested it on a little endian power8 system with a bootstrap compiler.  
> > There
> > were no regresion failures.  Can I check this into GCC 8?  This does not 
> > need
> > to be checked into GCC 7, since -mabi=ieeelongdouble was not fully 
> > supported in
> > that release.
> 
> > [libgcc]
> > 2018-04-18  Michael Meissner  <meiss...@linux.vnet.ibm.com>
> > 
> >     PR target/85456
> >     * config/rs6000/_powikf2.c: New file.  Entry point for
> >     __builtin_powil when -mabi=ieeelongdouble is in effect.
> >     * 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.
> 
> This changelog does not make too much sense ("__powikf2: Add __powikf2
> support." does not really say what it does, for example).

Ok, I will rewrite it.

> Does the leading underscore in the filename have any meaning?  The kc
> files have one, too, but everything else does not.

It comes from all of the libgcc2.c functions are compiled into _<op><mode>3,
etc.  I kept the same name for consistancy.

> > +#if defined(FLOAT128_HW_INSNS) && !defined(__powikf2)
> > +#define __powikf2 __powikf2_sw
> > +#endif
> 
> This could use a comment (it seems the wrong way around if you don't
> see how it is built).

Ok.

> > +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;
> > +}
> 
> This work correctly for the most negative integer.  Okay.

It is a copy of the code from libgcc2.c, so it should be correct :-)

For simple code like this and mulkc3/divkc3, it was simpler to just extract the
code from libgcc2, rather than add appropriate KC/KF support to libgcc2.c.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797

Reply via email to