patch to fix __builtin_powi failure on apple-ppc-darwin (revised)

Richard Guenther richard.guenther@gmail.com
Wed Mar 30 08:48:00 GMT 2005


On Tue, 29 Mar 2005 15:13:26 -0800, Fariborz Jahanian
<fjahanian@apple.com> wrote:
> 
> On Mar 29, 2005, at 2:54 PM, Richard Henderson wrote:
> 
> > On Tue, Mar 29, 2005 at 02:44:21PM -0800, Fariborz Jahanian wrote:
> >> Wtype is defined  by one of DItype, SItype, HItype or QItype, all
> >> integer  types of different sizes, and its selection
> >> is based on value of MIN_UNITS_PER_WORD. It has been used as type of
> >> the 2nd formal argument to
> >> __powi* (which expects a type 'int').
> >
> > NO.  Reread libgcc2.c -- powi* expects type "Wtype", not "int".
> 
> I meant to say implementation of __powi* expect an 'int'. Obviously
> prototypes
> use Wtype.
>
> >
> >> Also, it has already been used in at least one other place where
> >> return
> >> type of "int" is desitred; (in __ffs*).
> >
> > Well, that would be because __ffs *uses* "int" in libgcc2.c.
> > Obviously.

It does not:

#ifdef L_ffssi2
#undef int
int
__ffsSI2 (UWtype u)
{
  UWtype count;

it uses int as _return_ type, not as argument type.  Though it is declared as

DEF_EXT_LIB_BUILTIN    (BUILT_IN_FFS, "ffs", BT_FN_INT_INT,
ATTR_CONST_NOTHROW_LIST)

I chose to match the ffs way, so powi has Wtype for the int argument and is
declared as

DEF_GCC_BUILTIN        (BUILT_IN_POWI, "powi",
BT_FN_DOUBLE_DOUBLE_INT, ATTR_MATHFN_FPROUNDING)

> Yes.
> 
> >
> > Your change has broken (essentially) all 64-bit ports, where Wtype is
> > DImode, and int is SImode.
> >
> > Now, since powi is new to gcc 4.0, and 4.0 isn't released, we don't yet
> > have a fixed abi for this, so it would be reasonable to change the
> > prototype of the powi functions in libgcc2.c.  I rather assume this is
> 
> So you mean changing Wtype to 'int' and keeping my patch as is in
> setting up the call?
> It is reasonable.

So what do you suppose?  Using

TYPE
NAME (TYPE x, int m)
{
  unsigned int n = m < 0 ? -m : m;

etc.?  If this works for all targets and crosscompiling it would even match the
libstdc++ prototype for std::pow(X, int).

Richard.

> - fariborz
> 
> > what Geoff meant when he told you to use "int" in a previous message in
> > this thread.
> >
> >
> > r~
> 
>



More information about the Gcc-patches mailing list