2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gcc.target / s390 / target-attribute / tpragma-struct-vx-2.c
blob652b122aefddf4139a264b6305e21cd805fbf706
1 /* Functional tests for the "target" attribute and pragma. */
3 /* { dg-do run } */
4 /* { dg-require-effective-target target_attribute } */
5 /* { dg-require-effective-target s390_vx } */
6 /* { dg-options "-march=z13 -mvx -mzarch" } */
8 #define V16 __attribute__ ((vector_size(16)))
9 #pragma GCC push_options
10 #pragma GCC target ("arch=z900,no-vx")
11 __attribute__ ((noinline))
12 void foo (char *d, int *off)
14 typedef struct
16 char c;
17 V16 char vc;
18 } s_t;
19 s_t s = { 1,{ 0,11,22,33,44,55,66,77,88,99,101,111,121,131,141,151 }};
20 *off = __builtin_offsetof(s_t, vc);
21 __builtin_memcpy(d, &s.vc, 16);
23 #pragma GCC pop_options
25 #pragma GCC push_options
26 #pragma GCC target ("no-vx")
27 __attribute__ ((noinline))
28 void bar (char *d, int *off)
30 typedef struct
32 char c;
33 V16 char vc;
34 } s_t;
35 s_t s = { 1,{ 0,11,22,33,44,55,66,77,88,99,101,111,121,131,141,151 }};
36 *off = __builtin_offsetof(s_t, vc);
37 __builtin_memcpy(d, &s.vc, 16);
39 #pragma GCC pop_options
41 int main(int argc, char **argv)
43 char buf[16] = { 0 };
44 char buf2[16] = { 0 };
45 int off = 0;
46 int off2 = 0;
47 int rc;
49 rc = 0;
50 foo(buf, &off);
51 if (off != 16)
52 rc += 1;
53 if (buf[7] != 77)
54 rc += 2;
55 bar (buf2, &off2);
56 if (off2 != 16)
57 rc += 4;
58 if (buf2[6] != 66)
59 rc += 8;
61 return rc;