This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, i386]: Fix PR target/35553, -fkeep-inline-functions and -O errors our in SSE headers


On Thu, Mar 13, 2008 at 11:18:51AM +0100, Uros Bizjak wrote:
> Hello!
> 
> >  >  Fixed by introducing __SSE_USE_INLINED_FUNC__ builtin define that is
> >  >  defined when appropriate and by using this define through SSE headers.
> >
> >  Why not simply make these functions extern inline __attribute__((gnu_inline))?
> 
> Huh, indeed.
> 
> Do we need extern here or can go with static inline
> __attribute__((gnu_inline, _always_inline_))
> 
> (the tests that redefine "static" won't have to be updated in this case.)

gnu_inline attribute makes no difference for static inline functions, with
-fkeep-inline-functions they are emitted out of line.

You want
extern __inline __attribute__((__gnu_inline__, __always_inline__, __artificial__))
Probably the __OPTIMIZE__ guards are still needed, as eventhough the inlines
will be inlined at -O0, the constants might not be propagated into the
builtins, as can be seen on:
extern void baz (int);
extern __inline __attribute__((__gnu_inline__, __always_inline__, __artificial__))
void foo (int i)
{
  baz (i);
}
void bar (void)
{
  foo (6);
}
at -O0.
All static inlines in the headers should be changed btw, otherwise you can't
use the _mm_* inlines in e.g. extern inline functions.

Try e.g.:
#include <xmmintrin.h>

extern inline __attribute__ ((gnu_inline)) __m64 foo (__m64 x)
{
  return _mm_shuffle_pi16 (x, 0x1b);
}

__m64 x;

int
main (void)
{
  foo (x);
  return 0;
}
with -std=gnu99 -O2 and you'll get a warning, with -pedantic-errors even an
error:
'_mm_shuffle_pi16' is static but used in inline function 'foo' which is not static

Similarly when foo doesn't have gnu_inline attribute.  I think we had a PR
about this, though don't remember the PR number ATM.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]