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]

Altivec strangeness?


Hija,

I'm fooling around with altivec and tried to convert my sources, thereby
I discovered the following strangeness:

#include <altivec.h>

static const vector signed short test = {1, 2, 3, 4, 5, 6, 7, 8};

static const vector signed short test2[2] =
{
    {1, 2, 3, 4, 5, 6, 7, 8},
    {1, 2, 3, 4, 5, 6, 7, 8}
};

static const vector signed short test3[2] =
{
    {(1, 2, 3, 4, 5, 6, 7, 8)},
    {(1, 2, 3, 4, 5, 6, 7, 8)}
};

gives:

test.c:7: warning: braces around scalar initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:7: warning: excess elements in vector initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:7: warning: excess elements in vector initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:7: warning: excess elements in vector initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:7: warning: excess elements in vector initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:7: warning: excess elements in vector initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:7: warning: excess elements in vector initializer
test.c:7: warning: (near initialization for `test2[0]')
test.c:8: warning: braces around scalar initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:8: warning: excess elements in vector initializer
test.c:8: warning: (near initialization for `test2[1]')
test.c:13: warning: braces around scalar initializer
test.c:13: warning: (near initialization for `test3[0]')
test.c:14: warning: braces around scalar initializer
test.c:14: warning: (near initialization for `test3[1]')

I believe test2 should work and I added test3 only to try
whether the warning goes away.

And further: How do I initialize a vector with the same value
to all elements? 
static const vector signed short foo = {1};
gives me {1, 0, 0, 0, 0, 0, 0, 0, 0} as result which is loaded
from memory whilst a vector splat might be more efficient here.

-- 
Servus,
       Daniel


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