Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.c-torture / execute / vector-subscript-1.c
blob03647fd5074d61c97f56b92c9bb396dcfd6d878a
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, 16);
53 for(i = 0; i < 4; i++)
54 if (a[i] != i+1)
55 __builtin_abort ();
58 return 0;