This is the mail archive of the gcc@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]

Problems with pragma and attribute optimize.


Hi,

I have been experimenting with marking specific functions to be auto-
vectorized in GCC, but have had problems getting it to work.

It seems the optimize attribute works sometimes, but only if the function it 
is used on is not static, but pragma optimize never seems to work.

See the attached test-case. If you compile it with -ftree-vectorizer-verbose, 
you will see that only the first function is vectorized, but the two last are 
not. 

Anyone know what is wrong here?

Best regards
`Allan
#include <stdint.h>

void  __attribute__((optimize("tree-vectorize"))) innerloop_1(int16_t* destination, const int16_t* source1, const int16_t* source2, int length)
{
    while (length--) {
        *(destination++) = *(source1++) + *(source2++);
    }
}

static void  __attribute__((optimize("tree-vectorize"))) innerloop_2(int16_t* destination, const int16_t* source1, const int16_t* source2, int length)
{
    while (length--) {
        *(destination++) = *(source1++) + *(source2++);
    }
}

void caller(int16_t* destination, const int16_t* source1, const int16_t* source2, int length)
{
    innerloop_2(destination, source1, source2, length);
}

#pragma GCC optimize("tree-vectorize")

void innerloop_3(int16_t* destination, const int16_t* source1, const int16_t* source2, int length)
{
    while (length--) {
        *(destination++) = *(source1++) + *(source2++);
    }
}

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