RamblingMad
RamblingMad

Reputation: 5518

_mm_shuffle_ps not declared even though header included

Sometimes (not always) when I include my math headers in projects the compiler will complain (tried gcc and clang) that _mm_shuffle_ps and _mm_shuffle_pd were not declared even though all compiler flags are set (-msse -msse2 -msse3) and the correct headers are included (<x86intrin.h>).

Here is how I use the functions:

extern "C"{
    #include <x86intrin.h>
}    

template<typename T>
struct sse_type;

template<>
struct sse_type<float>{
    typedef __m128 type;

    constexpr static type(&shuffle)(type, type, int) = _mm_shuffle_ps;

    // other sse functions
};

template<>
struct sse_type<double>{
    typedef __m128d type;

    constexpr static type(&shuffle)(type, type, int) = _mm_shuffle_pd;

    // other sse functions
};

Then I define a bunch of operator overloads on those classes, for easier use.

This is how I use just those functions as the compiler does not complain about any other sse functions defined within those classes.

Remembering that the compiler does not always complain about this and that some projects compile fine with this header, what exactly could I be doing wrong here? or is this a compiler bug?

Upvotes: 1

Views: 561

Answers (1)

RamblingMad
RamblingMad

Reputation: 5518

Figured it out almost straight away after asking this question (although I've been trying to figure out this issue for hours now).

GCC will emit some sse functions from compilation if no optimization flags are set. weird.

Adding -O3 to my compilation flags does the trick.

So I still get errors in clang, but setting -O3 in gcc 4.8 fixes the error :/

Upvotes: 1

Related Questions