Altivec strangeness?
Daniel Egger
degger@fhm.edu
Fri Feb 22 08:25:00 GMT 2002
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
More information about the Gcc
mailing list