This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Altivec strangeness?
- From: Daniel Egger <degger at fhm dot edu>
- To: GCC Developer Mailinglist <gcc at gcc dot gnu dot org>
- Cc: Aldy Hernandez <aldyh at redhat dot com>
- Date: 22 Feb 2002 16:55:00 +0100
- Subject: 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