[PATCH] Optimize x*x*x*x*x*x using 3 multiplications.

Gabriel Dos Reis gdr@integrable-solutions.net
Tue Jul 29 21:02:00 GMT 2003


Roger Sayle <roger@eyesopen.com> writes:

| On 29 Jul 2003, Gabriel Dos Reis wrote:
| > | It might also be worth contacting the glibc/newlib folks to check that
| > | they don't already have a name for these functions, even if they don't
| > | have any immediate plans to provide implementations.  It would be
| > | unfortunate to have this functionality ratified by a future ISO C/C++
| > | standard, but under a different name (if its avoidable).
| >
| > Hmm, I'm not sure I understand the second paragraph.
| > Normally, glibc people are not supposed to provide an implementation to
| > anything named __builtin_xxx, am I wrong?
| 
| By convention, the name "xxx" used in "__builtin_xxx" attempts follow
| the naming and parameter passing conventions mandated by the C and C++
| standards.  Where possible if the same functionality exists then the
| same name should be used.

Aha, I know get what you meant by "name for these functions".  Yes, I
knew of that convention but for some reasons I could not understand
you meant that. 

I was thinking of those as purely internal to GCC, of the "class"
GCC_BUILTIN, not LIB_BUILTIN.

| For example in the C library, the suffix letters "l" and "f", by
| convention denote the float and long double forms of a function when used
| at the end of an identifier.  This would prefer "powif" over "powfi",
| for example.

Sure, I don't insist on powfi -- although powif looks odd to me
because the arguments are in the reverse order.

The C standard does not define any function like the one we're
discussing; but it provides the following Hungarian notation framework   

       [#1]  The  header  <math.h>  declares  two  types  and  many
       mathematical  functions  and  defines  several macros.  Most
       synopses specify a  family  of  functions  consisting  of  a
       principal  function  with  one  or more double parameters, a
       double return value, or both; and other functions  with  the
       same name but with f and l suffixes, which are corresponding
       functions with float  and  long  double  parameters,  return
       values,  or  both.189)   Integer  arithmetic  functions  and
       conversion functions are discussed later.

so go for powif for consistency.

[...]

| I hate naming things and if a higher authority can provide guidance,
| I'm more than happy to follow it.  C++'s STL isn't much of a help
| here because of the polymorphism.  Perhaps __builtin_Z3powdi?  But I
| now understand why you prefer the "f" and "l" before the "i" :>

I guess you understand why I can't handle Hungarian-like notation :-D

-- Gaby



More information about the Gcc-patches mailing list