re PR c++/54427 (Expose more vector extensions)
[official-gcc.git] / gcc / testsuite / c-c++-common / torture / vector-subscript-1.c
blobbb1350ebedcb7febcb159b69e5fefad46cab88af
1 /* { dg-do run } */
2 #define vector __attribute__((vector_size(sizeof(int)*4) ))
4 /* Check to make sure that we extract and insert the vector at the same
5 location for vector subscripting and that vectors layout are the same
6 as arrays. */
8 struct TV4
10 vector int v;
13 typedef struct TV4 MYV4;
14 static inline int *f(MYV4 *a, int i)
16 return &(a->v[i]);
19 static inline MYV4 myfunc2( int x, int y, int z, int w )
21 MYV4 temp;
22 *f(&temp, 0 ) = x;
23 *f(&temp, 1 ) = y;
24 *f(&temp, 2 ) = z;
25 *f(&temp, 3 ) = w;
26 return temp;
29 MYV4 val3;
31 __attribute__((noinline)) void modify (void)
33 val3 = myfunc2( 1, 2, 3, 4 );
36 int main( int argc, char* argv[] )
38 int a[4];
39 int i;
41 modify();
43 if (*f(&val3, 0 ) != 1)
44 __builtin_abort ();
45 if (*f(&val3, 1 ) != 2)
46 __builtin_abort ();
47 if (*f(&val3, 2 ) != 3)
48 __builtin_abort ();
49 if (*f(&val3, 3 ) != 4)
50 __builtin_abort ();
52 __builtin_memcpy (a, &val3, sizeof(a));
53 for(i = 0; i < 4; i++)
54 if (a[i] != i+1)
55 __builtin_abort ();
58 return 0;