OSDN Git Service

Backport from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / powerpc / pr52457.c
1 /* { dg-do run { target { powerpc*-*-linux* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3 /* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
4 /* { dg-require-effective-target vsx_hw } */
5 /* { dg-options "-O1 -mcpu=power7" } */
6
7 extern void abort (void);
8
9 typedef long long T;
10 typedef T vl_t __attribute__((vector_size(2 * sizeof (T))));
11
12 vl_t
13 buggy_func (T x)
14 {
15   vl_t w;
16   T *p = (T *)&w;
17   p[0] = p[1] = x;
18   return w;
19 }
20
21 int
22 main(void)
23 {
24   vl_t rval;
25   T *pl;
26
27   pl = (T *) &rval;
28   rval = buggy_func (2);
29
30   if (pl[0] != 2 || pl[1] != 2)
31     abort ();
32
33   return 0;
34 }