This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Problems with pragma and attribute optimize.
- From: Allan Sandfeld Jensen <carewolf at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 25 Jul 2012 14:23:27 +0200
- Subject: 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++);
}
}