]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/gcc.dg/torture/vector-2.c
re PR target/46280 (Several testcases FAIL with 16byte alignment ABI warning on Solar...
[gcc.git] / gcc / testsuite / gcc.dg / torture / vector-2.c
1 /* Check that vector insertion works correctly. */
2
3 /* { dg-do run } */
4 /* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */
5 /* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */
6
7 #define vector __attribute__((vector_size(16) ))
8
9 vector int f0(vector int t, int a)
10 {
11 ((int*)&t)[0] = a;
12 return t;
13 }
14 vector int f1(vector int t, int a)
15 {
16 ((int*)&t)[1] = a;
17 return t;
18 }
19 vector int f2(vector int t, int a)
20 {
21 ((int*)&t)[2] = a;
22 return t;
23 }
24 vector int f3(vector int t, int a)
25 {
26 ((int*)&t)[3] = a;
27 return t;
28 }
29 int main(void)
30 {
31 vector int a = {0, 0, 0, 0};
32 vector int b = {1, 0, 0, 0};
33 vector int c = {0, 1, 0, 0};
34 vector int d = {0, 0, 1, 0};
35 vector int e = {0, 0, 0, 1};
36 vector int a0;
37 a0 = f0(a, 1);
38 if (memcmp (&a0, &b, sizeof(a0)))
39 __builtin_abort ();
40 a0 = f1(a, 1);
41 if (memcmp (&a0, &c, sizeof(a0)))
42 __builtin_abort ();
43 a0 = f2(a, 1);
44 if (memcmp (&a0, &d, sizeof(a0)))
45 __builtin_abort ();
46 a0 = f3(a, 1);
47 if (memcmp (&a0, &e, sizeof(a0)))
48 __builtin_abort ();
49 return 0;
50 }
This page took 0.039959 seconds and 5 git commands to generate.