14c1e838e04dfd3fa1099207c85dc3417fe6958d
1 /* { dg-do compile { target { powerpc64le-*-* } } } */
2 /* { dg-require-effective-target powerpc_p8vector_ok } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O3 " } */
5 /* Previous versions of this test required that the assembler does not
6 contain xxpermdi or xxswapd. However, with the more sophisticated
7 code generation used today, it is now possible that xxpermdi (aka
8 xxswapd) show up without being part of a lxvd2x or stxvd2x
13 extern void abort (void);
16 const vector
int y
= { 0, 1, 2, 3 };
22 return y
; /* Remove 1 swap and use lvx. */
28 x
= y
; /* Remove 2 redundant swaps here. */
29 return x
; /* Remove 1 swap and use lvx. */
32 void __attribute__ ((noinline
))
33 fill_local (vector
int *vp
)
35 *vp
= x
; /* Remove 2 redundant swaps here. */
38 /* Test aligned load from local. */
44 /* Need to be clever here because v will normally reside in a
45 register rather than memory. */
47 return v
; /* Remove 1 swap and use lvx. */
51 /* Test aligned load from pointer. */
53 foo3 (vector
int *arg
)
55 return *arg
; /* Remove 1 swap and use lvx. */
58 /* In this structure, the compiler should insert padding to assure
59 that a_vector is properly aligned. */
68 return bp
->a_vector
; /* Remove 1 swap and use lvx. */
71 /* Test aligned store to global. */
75 x
= arg
; /* Remove 1 swap and use stvx. */
78 void __attribute__ ((noinline
))
79 copy_local (vector
int *arg
)
81 x
= *arg
; /* Remove 2 redundant swaps. */
85 /* Test aligned store to local. */
91 /* Need cleverness, because v will normally reside in a register
92 rather than memory. */
93 v
= arg
; /* Aligned store to local: remove 1
98 /* Test aligned store to pointer. */
100 baz2 (vector
int *arg1
, vector
int arg2
)
102 /* Assume arg2 resides in register. */
103 *arg1
= arg2
; /* Remove 1 swap and use stvx. */
107 baz3 (struct bar
*bp
, vector
int v
)
109 /* Assume v resides in register. */
110 bp
->a_vector
= v
; /* Remove 1 swap and use stvx. */
114 main (int argc
, int *argv
[])
116 vector
int fetched_value
= foo ();
117 if (fetched_value
[0] != 0 || fetched_value
[3] != 3)
120 fetched_value
= foo1 ();
121 if (fetched_value
[1] != 1 || fetched_value
[2] != 2)
124 fetched_value
= foo2 ();
125 if (fetched_value
[2] != 2 || fetched_value
[1] != 1)
128 fetched_value
= foo3 (&x
);
129 if (fetched_value
[3] != 3 || fetched_value
[0] != 0)
133 a_struct
.a_vector
= x
; /* Remove 2 redundant swaps. */
134 fetched_value
= foo4 (&a_struct
);
135 if (fetched_value
[2] != 2 || fetched_value
[3] != 3)
144 if (x
[0] != 7 || x
[3] != 4)
147 vector
int source
= { 8, 7, 6, 5 };
150 if (x
[3] != 6 || x
[2] != 7)
154 baz2 (&dest
, source
);
155 if (dest
[0] != 8 || dest
[1] != 7)
158 baz3 (&a_struct
, source
);
159 if (a_struct
.a_vector
[3] != 5 || a_struct
.a_vector
[0] != 8)